So I'm making a wishlist but am stuck at joining 2 MySQL tables together. At the moment I'm doing this by using following code:

   if ($stmt = $mysqli->prepare("SELECT ItemID FROM wishlist WHERE WishlistID = ?")) { 
        $stmt->bind_param("s", $this->ID);
        while ($product = $stmt->fetch()) { 

            if ($stmt2 = $mysqli2->prepare("SELECT FROM products WHERE = ?")) { 
                $stmt2->bind_param("s", $id);
                $page .= $name . "<br/>m<br/>";                                        


Now this ofcourse is a workaround. This was my code for the join that didn't work:

 if ($stmt = $mysqli->prepare("SELECT FROM wishlist,products WHERE wishlist.WishlistID = ? AND wishlist.ItemID =")) { 

where wishlist.WishlistID is the ID of the user's wishlist, stored in a php Session.

Help would be greatly appreciated..

Member Avatar

Have you read up on MySQL JOIN syntax? It's a good read - recommended

Anyway, try...

"SELECT FROM products AS p INNER JOIN wishlist AS w ON = w.ItemID WHERE w.WishlistID = ?"