Jump to content

Display Inner Join


Tenaciousmug

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/238424-display-inner-join/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/238424-display-inner-join/#findComment-1226084
Share on other sites

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.