need help to build a query

From: Date: Mon, 09 Oct 2006 19:44:40 +0000
Subject: need help to build a query
Groups: php.general 
Request: Send a blank email to php-general+get-242869@lists.php.net to get a copy of this message
hi to all, I have table orders with primary key order_id. I have table uploaded_files with primary key ufid and uploaded files are linked to orders by order_id column. I have to list all orders and uploaded files. this works fine: $query = mysql_query(" select order_id, order_date, order_status from orders order by order_id desc limit 100"); while($result=mysql_fetch_array($query)) { echo "ID: ". $result['order_date']."|"; echo "DATE: ". $result['order_date'] ."|"; echo "STATUS: ". $result['order_status'] ."|"; echo "UPLOADED FILES: "; $query2 = mysql_query(" select uf.file_name from uploaded_files as uf where uf.order_id = $result['order_id'] "); while($result2=mysql_fetch_array($query2)) { echo $result2['file_name']."|"; } echo "<hr>"; } but I know there must be much better solution then this one. thanks for any help. -afan

« previous php.general (#242869) next »