The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP multiple table Re: PHP multiple table


I was able to fix the sql statement to get all the information I needed but still need help on getting orders to appear on one line. Its reading every line in the DB as is should, if I have an order 119 and they ordered 4 items its displaying a line for each item that ordered. I’m trying to get it to do this:

order Item description color
119 Leash dog lead red
collar dog collar blue
120 food dog food
121 leash dog lead green

Below is the current working code, can any on lend a hand?


// { initialise variables
// }
// { connect to database
function dbRow($sql){
return $r;
function dbAll($sql){
return $rs;
// }
// { count existing records
$r=dbRow(‘select count(OrderID) as c from orders’);
// }
// { start displaying records
echo ‘{"iTotalRecords":’.$total_records.’,
$rs=dbAll("select * from orders, orderdetails where orderdetails.DetailOrderID = orders.OrderID ");
foreach($rs as $r){
if($f++) echo ‘,’;
echo ‘["’,$r[‘OrderID’],’",

echo ‘]}’;
// }