seany123 Posted July 29, 2009 Share Posted July 29, 2009 basically i have this code. <div class="g_content"><h3> Weapons</h3><div class="g_text"> <table align='center' cellspacing='10'> <?php $current_col = 1; $max_col = 4; $query = $db->execute("select * from items where `player_id`=?", array($player->id)); while($item = $query->fetchrow()) { $query2 = $db->execute("select * from `blueprint_items` where `id`=?",array($item['item_id'])); $item2 = $query2->fetchrow(); if($item2['type'] == 'weapon'){ if($item['status'] != 'equipped'){ //Open new row if first column if($current_col==1) { echo "<tr>\n"; } //Display current record echo "<td>"; echo "<center><img src=\"{$item2['img']}\" width='80' height='80' style=\"border: 1px solid #CC9900\"></center>"; echo "<center><a href=\"../description.php?id={$item2['id']}\">{$item2['name']}</a></center>"; echo "<center>[<a href='../item.php?sell=".$item['id']."'>Sell</a>] [<a href='../item.php?market=".$item['id']."'>Market</a>] <br>[<a href='../item.php?send=".$item['id']."'>Send</a>] [<a href='../item.php?equip=".$item['id']."'>Equip</a>]</center><br>"; echo "</td>\n"; //Close row if last column if($current_col==$max_col) { echo "<tr>\n"; $current_col = 0; //<---Changed } $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> what i wanna do is make it so if more than one $item->item_id that is the same is found... then to only show 1 but have it echo the amount found... so say i have 5 rows with the same $item->item_id.. it will only echo 1 row but then echo Quantity: 5 Quote Link to comment https://forums.phpfreaks.com/topic/167888-help-please/ Share on other sites More sharing options...
.josh Posted July 29, 2009 Share Posted July 29, 2009 research using SUM and GROUP BY in your mysql query Quote Link to comment https://forums.phpfreaks.com/topic/167888-help-please/#findComment-885504 Share on other sites More sharing options...
seany123 Posted July 29, 2009 Author Share Posted July 29, 2009 i don't see how i can stop the others being echo'd. Quote Link to comment https://forums.phpfreaks.com/topic/167888-help-please/#findComment-885950 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.