Jump to content

[SOLVED] PHP displaying fields of table that have same date


SocomNegotiator

Recommended Posts

Ok well right now my database is setup so that the user adds a single item to a pre_order table to their "cart" one by one. So each item has a different id. Now when they go to "checkout" I made it so that the info in the pre-order table gets transfered to the order table and then the info in the pre-order table for that user gets deleted. Well each user may have multiple orders. One order may have 4 items while another will have 10 items. Each item will have a different id even though when the order was purchased it will have a different id, but they will have the same date. Now I need to figure out a way how I can display each individual order based upon date. So the items that have the same date will be displayed together showing that they were ordered together as that users first order....then the next set of items with the same date will be order #2, and so on

 

Do I need to put a while statement saying?

 

while(date=date)  {
-display the items with the same date...
-next set of same dates will be displayed below
-and so on
}

<?php

   $sql = "SELECT * FROM table1,table2 WHERE table1.date= '$date' && table2.date= '$date'";
   $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error());
   $row = mysql_fetch_assoc($rs);

$result = <<<_RESULT
<h1>Order</h1>
<ul>
<li>{$row['item']}</li>
<li>{$row['date']}</li>
</ul>
_RESULT;

echo $result;

?>

 

try something like that.

 

Regards ACE

<?php

    $sql = "SELECT * FROM table1,table2 WHERE table1.date= '$date' && table2.date= '$date'";
    $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error());
    $row = mysql_fetch_assoc($rs);

$result = <<<_RESULT
<h1>Order</h1>
<ul>
<li>{$row['item']}</li>
<li>{$row['date']}</li>
</ul>
_RESULT;

echo $result;

?>

 

try something like that.

 

Regards ACE

 

 

It is not two tables though...the items are in one table. However 5 different items may be with the same order. So in other words 5 items "purchased" will have the same date. And I need to use the date some how to get those items that were "purchased" at the same time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.