Fixing Data Row Callback [Resolved]
Posted: Fri Sep 13, 2013 7:06 pm
Okay, I have where you can click on your items and it lists the items in the inventory, but the problem is that it lists ALL the items from EVERYONE. I'm not sure how I did that, but it only needs to show what items that specific user has. Here is what code I have for recalling from database.
I tried changing to the code below, but still shows everything in the inventory table:
So, example: I have 3 coffee's under my id, but shows I have a total of 5 coffee's because of the other person that has 2 of them. lol... Not supposed to work that way LOL
Code: Select all
<?php
$id = $user['id'];
$counter = 0;
$invinfo = ("SELECT count(*) as total, name, stats, price, statadd, randid, type FROM inventory GROUP BY name having count(*) > 0 ");
$invinfo2 = mysql_query($invinfo) or die ("Could not select inventory");
while ($row = mysql_fetch_assoc($invinfo2)) {
$cur_item = $row['name'];
if($row['type'] == 'healing' || $row['type'] == 'revive' )
{
?>
<div>
<div align="left" class="itemleft"><?php echo $row["name"]; ?></div>
<div align="center" class="itemcenter"><?php echo $row["total"]; ?></div>
<div align="center" class="itemright">Adds: <?php echo $row["statadd"]; ?></div>
<input type="hidden" id="hidden" name="hidden" value="<?php echo $row["id"]; ?>">
<div align="left"><?php echo "<A href='battle1.php?randid=$row[randid]'?><font color='red'>Use Item" ?></a></font></div>
<br />
</div>
<?php
Code: Select all
$invinfo = ("SELECT count(*) as total, name, stats, price, statadd, randid, type FROM inventory GROUP BY name having count(*) > 0 AND $id= $user[id]");