Jump to content

Divide a value from a query ?!


bine.heckmann

Recommended Posts

Hello everyone,

 

i'm trying to get the following scenario done:

 

I've got a shop system which is kind of a cms and shop in one thing but that's not really important here, now there's some kind of vouchers which can be used in my shop to fund the account balance aka "Credits", now everything works fine, my script checks the voucher for validity and balance and the user gets the voucher balance credited as his account balance, in short:

 

User1 uses Voucher with amount 10$

Script sets User1 Shop-Credits/Balance to 10$

 

Now what i want to achieve is, that the user get's only 50% of the original voucher amount credited to his shop-credits/balance basically just divide the voucher amount by 2 before it get's credited to the account.

 

My code to write/update the credits in mySQL looks like this:

 

$query2 = "UPDATE `shop_user` SET `credits` = `credits`+'".$psc->value."' WHERE `userid` = '".$_SESSION["userid"]."' AND `username` = '".$_SESSION["username"]."'";

 

Now this

.$psc->value.

is the part where it checks for the value first and then sets the same amount as "credits" in the shop.

 

Now isn't there just some simple piece of code that would let me divide this by 2, which would be 50% obviously.

 

something like

.$psc->value /2.

which obviously doesn't work, but should give you an idea of what i need.

 

Any help is greatly appreciated.

 

Sabine

 

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.