seany123 Posted August 25, 2009 Share Posted August 25, 2009 i need some help with this code.... all i wanna do is make it so if $item['item_id'] has a record count of 2 or more... then to make it only echo it once... but have it say for example qty: (recordcount) <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> Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/ Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 Still unable to work this out!! Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-910308 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 so from this..... <?php $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(); basically i need to do this... <?php if ($item['item_id']->recordcount() <= 1) { } else if ($item['item_id']->recordcount() >= 2) { } but obviously that doesnt work? Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-910321 Share on other sites More sharing options...
Mark Baker Posted September 1, 2009 Share Posted September 1, 2009 $query = $db->execute("select itemid,count(*) as recordcount from items where `player_id`=? group by itemid", array($player->id)); Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-910388 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 doing that i echo'd it and got this output: item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 item_id,recordcount 1,55 2,3 3,1 18,1 im so confused. Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-910406 Share on other sites More sharing options...
seany123 Posted September 1, 2009 Author Share Posted September 1, 2009 Okay so i now have a working query.. $query3 = $db->execute("select * from `items` where `player_id`=? and `item_id`=?", array($player->id, $item['item_id'])); echo $query3->recordcount(); the echo also echo's the correct amount. but now i need to find a way for it to only echo only 1 of the rows where the recordcount is >= 2 instead of echoing them all still. Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-910458 Share on other sites More sharing options...
seany123 Posted September 2, 2009 Author Share Posted September 2, 2009 i tried using limit = 1 etc but i cant seem to get it working. Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-911001 Share on other sites More sharing options...
seany123 Posted September 4, 2009 Author Share Posted September 4, 2009 Im still struggling with this so if anyone knows how i could do it, it would be great!! Link to comment https://forums.phpfreaks.com/topic/171799-help-needed/#findComment-912107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.