Jump to content

Help please


x_mystico

Recommended Posts

Firstly. My Code.


$itemid = $_GET['id'];
$sq = mysql_query("select * from `shop` where `id` = '$_GET[id]' ")or die (mysql_error());
$shop = mysql_fetch_array($sq);$invent= mysql_query("select * from items where `iid` = '$shop[id]'") or die(mysql_error());
$count = mysql_num_rows($invent);
$upd = $invent1[amount]-1;
if($count ==1){
mysql_query("delete from `items` where `iid`='$shop[id]' and `uid` = '$logged[id]' ");
    }elseif($count <=1){
$upd = $invent1[amount]-1;
mysql_query("update `items` set `amount` ='$upd' where `uid` = '$logged[id]' and `iid` = '$shop[id]' ")or die(mysql_error());
}
echo"item used:$shop[name]";

 

 

 

 

My Error is with the count

What i want it to do, is if the var $invent1[amount] is more than 1, to take away 1 from it. e.g Amount(5)-1 =4

or if $invent1[amount] is only 0, to delete that row from the table.

 

With my coding,No matter the value of $invent1[amount], It's always deleting that row from the table.

 

 

 

Could anyone help me please?

Link to comment
https://forums.phpfreaks.com/topic/221336-help-please/
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.