You can do that in PHP, but that would be stupid when you are using a database which does this naturally.
You know it would have been helpful had you responded appropriately to my previous comment
Are those values for Player ID and Item ID really arrays or is that just how the functions work?
Since you did not provide the information up front I went the extra step to at least tell you what my assumptions were. But, then you failed to correct my false assumption. Had you done so we would have solved this earlier. Now that I know those values really are arrays, I'm pretty sure this will work to 1) use a single query and 2) add the ability to group the records.
<div id="left_c"><div class="g_content"><h3> Your Points</h3><div class="g_text">
<table width="100%" align="center" cellspacing="10">
<?php
$current_col = 1;
$max_col = 4;
$query = "SELECT b.item_id, b.name, b.img, COUNT(b.item_id) as item_count
FROM items i
LEFT JOIN `blueprint_items` b
ON items.item_id = blueprint_items.item_id
WHERE i.player_id IN ('" . implode("', '", array($player->id)) . "')";
$result = $db->execute($query);
while($record = $result->fetchrow())
{
//Open new row if first column
if($current_col==1)
{
echo "<tr>\n";
}
//Display current record
echo "<td>";
echo "<a href=\"../item.php?id={$result['item_id']}\">{$result['name']} ({$result['item_count']})</a><br>";
echo "<img src=\"{$result['img']}\" width=\"100\" height=\"100\" style=\"border: 1px solid #cccccc\">";
echo "</td>\n";
//Close row if last column
if($current_col==$max_col)
{
echo "<tr>\n";
$current_col = 1;
}
$current_col++;
}
//Close last row if needed
if ($current_col!=1)
{
for(; $current_col<=$max_col; $current_col++)
{
echo "<td> </td>\n";
}
}
?>
</table>
</div></div></div>I give no guarantees this will work. but if it doesn't at least provide soe information of what didn't work right and do some
simple debugging in order to help you further. For example, echo out the query so we can ensure it is being created properly