[prev in list] [next in list] [prev in thread] [next in thread]
List: php-db
Subject: Re: [PHP-DB] show data from 2 tables
From: Rolf Brusletto <rolf-list () triculture ! com>
Date: 2003-10-28 17:33:45
[Download RAW message or body]
ddhull@ku.edu wrote:
> 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
>
>
>
Doug -
the data would actually be accessed as the actual fieldnames without the
"tablename."
while($row=mysql_fetch_assoc($result))
{
foreach($row as $key => $value) {
echo '$row['.$key.'] => '.$value.'<br />';
}
echo '<br />';
}
the above snippet will allow you to see the values being passed to $row
by mysql_fetch_assoc();
hope this helps,
Rolf Brusletto
www.phpExamples.net
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic