Return values based on results of another table.
Posted: Tue Mar 09, 2010 9:02 am
So I'm trying to return values from one table based on the results of another. The problem is that the way I have it now it won't allow me to use ORDER BY because it's working with one value at a time. Could anyone propose an alternate way to do this?
Code: Select all
$getcategories = tep_db_query("SELECT * FROM products_to_categories WHERE categories_id ='" . $category . "'")
or die ("Couldn’t execute query.");
while ($row = tep_db_fetch_array($getcategories))
{
extract($row);
$getproducts = tep_db_query("SELECT products_name products_price FROM products WHERE products_id ='" . $products_id . "'");
while ($rname = tep_db_fetch_array($getproducts))
{
extract ($rname);
echo "print results";
}
}