It's only displaying the first result and not the others. What am I doing wrong?
I'm selecting the items the user occupies.
Then I'm selecting the name and image of that item from the item table.
echo "<table cellspacing=\"0\" class=\"news\" align=\"center\">";
echo "<tr>";
$sql = "SELECT * FROM useritems WHERE userid='".$_SESSION['userid']."' LIMIT $offset, $rowsperpage"; //selects all the users items to whoever is logged in
$result = mysqli_query($cxn,$sql) or die(mysqli_erro($cxn));
$imagecount = 0;
while ($row = mysqli_fetch_assoc($result)) //while there are still results
{
extract($row);
$quantity = $row['quantity'];
$itemid = $row['itemid'];
$sql = "SELECT * FROM items WHERE itemid='".$itemid."'"; //selecting the name and image of the item that is displaying
$result = mysqli_query($cxn, $sql) or die(mysqli_error($cxn));
$row = mysqli_fetch_assoc($result);
$name = $row['name'];
$image = $row['image'];
if ($imagecount%5 == 0) //after 5 items have been listed, start a new line
{
echo "</tr>";
echo "<tr>";
}
}
echo "<td width=\"120px\" align=\"center\">";
echo "<img src=\"http://www.elvonica.com/".$image."\"><br>";
echo $name." (".$quantity.")";
echo "</td>";
$imagecount++; //after one item has been displayed, redo the loop if there are still results
}
echo "</table>";