PDA

View Full Version : echo a query result


jtrechter
04-29-2005, 06:40 AM
If I have a query:

$sql= mysql_query("SELECT a.id, b.id FROM table1 a, table2 b WHERE a.id=b.id");
$get= mysql_fetch_query($sql);

Normally, if the query is selecting just from one table, then I just use:
echo $get[id]

But how do you output both a's id and b's id?
I tried echo $get[a.id] but it doesnt work. Thanks.

amir
04-29-2005, 01:55 PM
try it.

$sql= mysql_query("SELECT a.id as aid, b.id as bid FROM table1 a, table2 b WHERE a.id=b.id");
$get= mysql_fetch_query($sql);

echo $get[aid]
echo $get[bid]

jtrechter
04-30-2005, 10:57 PM
works like a gem! thanks :)