BecksDark Posted April 19, 2009 Posted April 19, 2009 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? Quote
POG1 Posted April 19, 2009 Posted April 19, 2009 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; } } Quote
BecksDark Posted April 19, 2009 Author Posted April 19, 2009 Re: Help with needing more than one item works a-ok +1 mate! 8-) Quote
AlabamaHit Posted April 19, 2009 Posted April 19, 2009 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; } Quote
POG1 Posted April 20, 2009 Posted April 20, 2009 Re: Help with needing more than one item you would want to use num rows to check if a result set is returned. Quote
AlabamaHit Posted April 20, 2009 Posted April 20, 2009 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 Quote
POG1 Posted April 21, 2009 Posted April 21, 2009 Re: Help with needing more than one item yes you do Quote
AlabamaHit Posted April 21, 2009 Posted April 21, 2009 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. Quote
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.