SocomNegotiator Posted July 24, 2008 Share Posted July 24, 2008 Ok I have a left join that takes an id from one table and then equals it to another fields table...but the result is not working for some odd reason: <?php $db->query('SELECT item.id, item.name, order.amount, order.item_id FROM `order` LEFT JOIN `item` ON order.item_id = item.id WHERE order.user_id='.$user_id) or die(mysql_error()); $iteminf = $db->fetch_array(); //I just made this so you can see how I am calling the variable echo $iteminf['name']; ?> What I have here displays a blank result...I have checked the DB and there are orders that have the item_id the same as the item tables id. So it should grab those items name based on the id being the same as in the order table, but it's not....any ideas? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted July 24, 2008 Share Posted July 24, 2008 you could try this $db->query("SELECT item.id, item.name, order.amount, order.item_id FROM `order` LEFT JOIN `item` ON order.item_id = item.id WHERE order.user_id='$user_id'") or die(mysql_error()); note the double quotes arround the query string and single quotes around the php variable print_r($iteminf); should tell you whats exactly in the returned array Quote Link to comment Share on other sites More sharing options...
SocomNegotiator Posted July 24, 2008 Author Share Posted July 24, 2008 Ah that worked...I hate it when its something so simple like quotes. Thanks man! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.