Jump to content
MakeWebGames

Recommended Posts

Posted

I'm using

$itemid = X;
     $i=$db->query("SELECT * FROM inventory WHERE inv_itemid=$itemid AND inv_userid=$userid");
if(mysql_num_rows($i) < 2)
{
print "<h2>Sorry</h2>You don't have any $%#$";
$h->endpage();
exit;
}

 

But if I have 2 items, it'll say the sorry message...any help?

Posted

Re: Help with needing more than one item

It will store it as qty and not each individual row, thats why num rows isnt working. Try using the inv_qty

 

$itemid = X;
$i = $db->query("SELECT * FROM inventory WHERE inv_itemid=$itemid AND inv_userid=$userid");

if(mysql_num_rows($i)) {

 $item = mysql_fetch_array($i,MYSQL_ASSOC);
 if($item['inv_qty'] < 2) { 

   print "<h2>Sorry</h2>You don't have any $%#$";
   $h->endpage();
   exit;

 }
}
Posted

Re: Help with needing more than one item

I would use this no neeed to use num rows.

 

$get_i = sprintf("SELECT inv_qty FROM inventory WHERE inv_itemid = NUMBERHERE AND inv_userid = %u",($userid));
$i = db->query($i);
$ii = $db->fetch_row($i);
if($ii['inv_qty'] < 2)
{
print "<h2>Sorry</h2>You don't have any $%#$";
$h->endpage();
exit;
}
Posted

Re: Help with needing more than one item

Acutally no.

Think about it like this. What if all items are qualified. Thne they will always have a num rows less than 2..

Don't do num rows here :-P

Posted

Re: Help with needing more than one item

what ever makes you feel better. I don't post unless i nkow it works. I know you don't need it here. and its pointless you just slowing down the page. I'm not posting back on this topic cuase your the kind of person that when thinks he is right will not listen.

If you want to use the num rows it will work. Its a waist of typing. Waist of server lag for checking. I honestly don't care.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...