I got a sql table containing a string that i need to join in another table. First i got the string from the SQL table:
$sql = "Select coupons.restrict_to_products From coupons Where coupons.coupon_id = 2"; $result = mysql_query($sql); $row = mysql_fetch_row($result); $array2=implode(",", $row); So if I now echo $array2it shows me "42, 43, 73" which is what i needed. Now i am trying to join another table with the result like this:
$query = mysql_query("SELECT products_name FROM products_description WHERE products_id IN ($array2)"); while ($row2 = mysql_fetch_assoc($query)) { $array3=implode(",", $row2); echo $array3."<br>"; } The code works but for some reason it shows me every productname 3 times and not only once. The result of the echo is:
Productname 1 Productname 1 Productname 1 Productname 2 Productname 2 Productname 2 Productname 3 Productname 3 Productname 3 What am I missing?