Jump to content

help needed


seany123

Recommended Posts

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

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.