mysql - Php select from two tables not working correctly -


hello have 2 tables

seo_settings

| cat_id | cat_fullname |  | 971    | catname 1    | | 443    | catname 2    | 

jcategories_to_hcategories

| jcategory_id | hcategory_id | | 1            | 971          | | 2            | 443          | | 3            | 443          | 

and want cat_fullname category id

i using

$catids = array(1,2,3)  foreach($catids $catid) { $sql3 = mysql_query("select a.cat_fullname seo_settings a, jcategories_to_hcategories b  a.cat_id = b.hcategory_id , b.jcategory_id = $catid ");     $data3 = mysql_fetch_array($sql3); } 

but $data3 return booleanfalse

important there rows , connected correctly assume there problem in sql probably.

try this

$catids = array(1,2,3);  $query = " select a.cat_fullname  seo_settings  left join jcategories_to_hcategories b on jcategories_to_hcategories b  b.jcategory_id in (".implode(",", $catids).") "; $sql3 = mysql_query($query) or die(mysql_error()); while($data3 = mysql_fetch_assoc($sql3)) {     echo $data3['cat_fullname'].'<br>'; } 

side note: stop using mysql_ , switch mysqli_ or pdo.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -