show data from 2 tables
| From: | ddhull at ku dot edu | Date: | Tue, 28 Oct 2003 17:20:21 +0000 |
| Subject: | show data from 2 tables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-31331@lists.php.net to get a copy of this message | ||
I am attempting to pull data from 2 tables. My SELECT statement seems ok. But the next line: while
... etc. is giving me an error of "Supplied argument is not a valid MySQL result
resource.". But this is the way I usually show my data and it works fine when only 1 table is
involved. Is there a different way of showing your data when pulling data from more than one table?
$result = @mysql_query('SELECT orders.orderid, orders.amount, orders.date
from customers, orders WHERE customers.name = "Don Hansen" and
customers.customerid = orders.customerid');
while ( $row = mysql_fetch_array($result) )
{
$zorderid = $row['orders.orderid'];
$zamt = $row['orders.amount'];
echo (str_pad($zorderid,4,' ') . str_pad($zamt,6, ' ') .
'<br>');
}
Thanks,
Doug