$query = "SELECT categories_name, parent_id FROM categories_description JOIN categories ON (categories_description.categories_id = categories.categories_id) WHERE language_id = 1 AND categories_description.categories_id IN (".$cPathArray.")"; $category_query = mysql_query($query);
// now we need to do a loop to get all the data :) for ($i=0;$i<$cPathArrayCount;$i++) { $query = "SELECT categories_name, parent_id FROM categories_description JOIN categories ON (categories_description.categories_id = categories.categories_id) WHERE language_id = 1 AND categories_description.categories_id = ".$cPathArray[$i]; $category_query = mysql_query($query); $category = mysql_fetch_assoc($category_query);
Your code still creates a potentially unlimited number of calls to the DB where mine makes a single query. This probably wouldn't be an issue for a small site but that many queries will potentially create problems if the site starts to grow.
Bookmarks