Ryno
-
Posts
6 -
Joined
-
Last visited
Never
Posts posted by Ryno
-
-
No. Is it only displaying the info from the first record in the orders table.
-
Not really. Its displaying the 1st record four times, and the second once.
-
Ive changed the code like this:
<?php $rs = mysql_query("SELECT p.id, p.name FROM Products p, Orders o WHERE p.id = o.ordered order by p.name ASC"); $row = 0; while(mysql_fetch_row($rs)) { $id = mysql_result($rs, $row, "id"); $name = mysql_result($rs, $row, "name"); echo "The product called $name has the id $id.<br />"; ++$row; } ?>
But it just displays this
The product called koo has the id 2.
The product called Test1 has the id 1.
The product called Test1 has the id 1.
The product called Test1 has the id 1.
How can I make it display the names of the products selected?
-
Okay Thanks.
Ive changed it to
<?php $product_order = mysql_query('SELECT id, name FROM Products p, Orders o WHERE id = o.id') ?>
Now can I just echo $product_order. Have I changed the query right?
-
Okay I've Read http://www.phpfreaks.com/forums/index.php/topic,203921.msg923805.html on query's but I'm not sure how to make it work. I have a shopping cart the same as that post but i'm not sure how to do that. I have the ids of the products ordered in Orders->ordered like this 1,3,2,1,3,4 but the name of the products is in Products->name and the id column in that table is ID.
How can i make it select the ID in the products table from the orders table and display the name from the name column?
Select Name From ID In A Different Table
in Third Party Scripts
Posted
Dont worry anymore Its getting too confusing.