hi r937
thanks for the reply.
the above problem is solved.
A new problem has arisen.
can you help me with it.
order_table contains order_id and order_total
order_details table contains order_id,product_name, quantity, price
now i want to display order_id and order_total only once
But want to show all products from order_detail_table associated with that order_id under it.
Problem i am facing is order_id is inside while loop
$q = "select nw.order_id,nw.order_total,odt.product_name,odt.quantity,odt.price from order_table as nw
inner join order_details as odt
on nw.order_id=odt.order_id
where nw.order_id=751";
$result = mysql_query($q);
while($row = mysql_fetch_array($result))
{
echo $row['order_id'];
echo "<br>";
echo $row['order_total'];
echo "<br>";
echo $row['product_name'];
echo "<br>";
echo $row['quantity'];
echo "<br>";
echo $row['price'];
echo "<br>";
}
so if there are two products to be shown then “order_id” is displayed two times.
The above code outputs results as
**order_id = 751**
order_total = 1025.00
product_name = nokia mobile
quantity = 2
price = 250.00
**order_id = 751**
order_total = 1025.00
product_name = samsung mobile
quantity = 3
price = 175.00
if i take out “order_id” out of while loop then while loop outputs only 1 LAST product, not all.
$q = "select nw.order_id,nw.order_total,odt.product_name,odt.quantity,odt.price from order_table as nw
inner join order_details as odt
on nw.order_id=odt.order_id
where nw.order_id=751";
$result = mysql_query($q);
$row = mysql_fetch_array($result);
echo $row['order_id'];
echo "<br>";
echo $row['order_total'];
echo "<br>";
while($row = mysql_fetch_array($result))
{
echo $row['product_name'];
echo "<br>";
echo $row['quantity'];
echo "<br>";
echo $row['price'];
echo "<br>";
}
How can i display “order_id” only once but all products below it.
order_id = 751
order_total = 1025.00
product_name = nokia mobile
quantity = 2
price = 250.00
product_name = samsung mobile
quantity = 3
price = 175.00
How can i display “order_id” only once but all products below it like the above example.
i dont want to display order_id again and gain after every product.
vineet