SocomNegotiator Posted July 16, 2008 Share Posted July 16, 2008 Ok well I am trying to grab information from two tables based on the info. in one table. So there are three tables involved. I have a user table, item table, and a pre_order table. The pre_order table has the item_id, user_id, and amount/quantity. Now I want to take those fields and use a left join so I can create a page that will show the user what they have in "their cart" essentially. Here is what I have... <?php $user_id = $user->inf['id']; $lname = $user->inf['last_name']; $db->query('SELECT docj_user.id, item.id, item.name, item.description, pre_order.amount FROM pre_order LEFT JOIN item ON pre_order.item_id = item.id LEFT JOIN docj_user ON pre_order.user_id = docj_user.id') or die(mysql_error()); $count = $db->num_rows(); if ($count == 0) { echo "<br /><div id='case'><p align='center' style='color: red;'>You have no orders to view.</p></div>"; } ?> <style type="text/css"> .menu22 ul{ margin: 0px; padding: 0px; float: left;} .menu22 ul li{ display: inline; margin:2px 5px 5px 20px;} </style> <div class="menu22" align="left"> <ul> <?php while($row = $db->fetch_array()) { ?> <form id='order_form' action='?page=view_item' method='post'><input type='hidden' name='user_id' value='<?=$row['docj_user.id']?>'/> <li> <ul style="width: 200px; height: 125px;"> <li>Item Name: <?=$row['item.name']?></li><br /> <li>Description: <?=$row['item.description']?></li><br /> <li>Quantity: <?=$row['pre_order.amount']?></li> </ul> </li> </form> <?php } ?> </ul> <br style="clear: left" /> </div> Now the code here brings up the correct amount of fields that user has because of the count variable I have. However, it is not bringing up the docj_user.id for the hidden field or any of the variables for the list. Any ideas would be much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/115135-phpmysql-left-join-problem/ Share on other sites More sharing options...
sader Posted July 16, 2008 Share Posted July 16, 2008 How looks function fetch_array() Link to comment https://forums.phpfreaks.com/topic/115135-phpmysql-left-join-problem/#findComment-592087 Share on other sites More sharing options...
xtopolis Posted July 17, 2008 Share Posted July 17, 2008 I do not know a lot about this myself, but you might try reading this mysql join tutorial by Barand http://www.phpfreaks.com/tutorial/data-joins-unions I know it contains info on LEFT JOIN, but I don't understand it well enough to help ya. sorry. Link to comment https://forums.phpfreaks.com/topic/115135-phpmysql-left-join-problem/#findComment-592120 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.