SocomNegotiator Posted July 17, 2008 Share Posted July 17, 2008 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 } Link to comment https://forums.phpfreaks.com/topic/115327-solved-php-displaying-fields-of-table-that-have-same-date/ Share on other sites More sharing options...
SocomNegotiator Posted July 17, 2008 Author Share Posted July 17, 2008 I may have to do a while inside of a while....because if i do date=date the date is going to always be the same then Link to comment https://forums.phpfreaks.com/topic/115327-solved-php-displaying-fields-of-table-that-have-same-date/#findComment-592921 Share on other sites More sharing options...
MasterACE14 Posted July 17, 2008 Share Posted July 17, 2008 <?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 Link to comment https://forums.phpfreaks.com/topic/115327-solved-php-displaying-fields-of-table-that-have-same-date/#findComment-592922 Share on other sites More sharing options...
SocomNegotiator Posted July 18, 2008 Author Share Posted July 18, 2008 <?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. Link to comment https://forums.phpfreaks.com/topic/115327-solved-php-displaying-fields-of-table-that-have-same-date/#findComment-593064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.