Tenaciousmug Posted June 4, 2011 Share Posted June 4, 2011 How do I display these two inner joins in a while loop? $sql = "SELECT w.userid, w.itemid, i.itemid, i.image, h.itemid, h.gender, h.image, h.type FROM {wardrobe} w INNER JOIN {items} i ON w.itemid = i.itemid INNER JOIN {hawearables} h ON i.itemid = h.itemid WHERE w.userid='".$_SESSION['userid']."' AND h.type='Top'"; $result = mysqli_query($cxn, $sql); This is what I keep putting: $sql = "SELECT w.userid, w.itemid, i.itemid, i.image, h.itemid, h.gender, h.image, h.type FROM {wardrobe} w INNER JOIN {items} i ON w.itemid = i.itemid INNER JOIN {hawearables} h ON i.itemid = h.itemid WHERE w.userid='".$_SESSION['userid']."' AND h.type='Top'"; $result = mysqli_query($cxn, $sql); while ($row = mysqli_fetch_assoc($result)) { $image = $row['items.image']; $tableOutput = "<img src=\"http://www.elvonica.com/".$image."\">"; } But then I get this error: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home1/elvonica/public_html/wardrobe/change.php on line 21 Quote Link to comment Share on other sites More sharing options...
gizmola Posted June 6, 2011 Share Posted June 6, 2011 Your query is generating an error. Your code does not check for that or display what the error is. Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 6, 2011 Share Posted June 6, 2011 Your problem is with all the curly braces around the table names - that is invalid code. The only reason to use curly braces in that context would be if you were enclosing variables to be replaced by PHP when parsing the string. But, if that was the case, then the variables would be preceded with a dollar sign. If those are variables, then include the dollar sign. If those are the actual table names then remove the curly braces. 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.