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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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...

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.