need help to build a query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux