I have the following query:
$query_q_pass = sprintf("SELECT * FROM answers INNER JOIN users WHERE a_id = %s and answers.user_id = users.user_id");
$q_pass = mysql_query($query_q_pass, $cd) or die(mysql_error());
$row_q_pass = mysql_fetch_assoc($q_pass);
Now the answers table from above query has a row brand_url which has many different values separated with commas, e.g. dell, microsoft, hp, ...
What I want to do is select all those values from the brand_url row and add them in another query where I will extract all brands that exist inside brand_url. This is the other query:
$query_conn_brands = 'SELECT * FROM brands WHERE brand_url = 'VALUE FROM ABOVE QUERY'';
$conn_brands = mysql_query($query_conn_brands, $cd) or die(mysql_error());
$row_conn_brands = mysql_fetch_assoc($conn_brands);
$totalRows_conn_brands = mysql_num_rows($conn_brands);
I tried many diferent ways using arrays but all I get is all results from the brands table. This is my last unsuccessful try:
$brand_pass_ids = $row_q_pass['brand_id'];
$array = array($brand_pass_ids,);
$query_conn_brands = 'SELECT * FROM brands WHERE brand_url IN (' . implode(',', array_map('intval', $array)) . ')';
$conn_brands = mysql_query($query_conn_brands, $cd) or die(mysql_error());
$row_conn_brands = mysql_fetch_assoc($conn_brands);
$totalRows_conn_brands = mysql_num_rows($conn_brands);
From the above example all I get is ALL results from brands table and not only those that exist inside answers table. I really hope someone will help me with this.
Thanks a lot!