Jump to content

Multiply/Addition php mysql help?


jurass1c

Recommended Posts

Heja

 

I have a MySQL database which contains information of members and the current balance of there accounts (eg: $1000) it also shows there current gain (eg: 1.2%) what i have been doing is individually updating each clients percent and balance. What i'm trying to work out is how to add a percent gain for the week and both the percent and balance of the clients are updated according to the submitted gain for example:

 

Client 1 has $1,000 and has a current gain of 1.5%

Client 2 has $,2000 and has a current gain of 2.5%

 

I want to update both clients by 1.5% and then both clients be updated like so:

 

Client 1 would now have $1,010.50 and now has a gain of 3.0%

Client 2 would now have $2,020.50 and now has a gain of 4.0%

 

I was looking around and could find much information on the internet or exactly has this can be achieved so i started to work on a addition and try atleast add the % however it dont go accordingly, i suppose im very rusty at my php. I started working around something  like this:

 

mysql_select_db('mem') or trigger_error("SQL", E_USER_ERROR);

$a1 = mysql_query("SELECT profits FROM account"); 

$a= $a1; 
$b=$b1;    /* html <input type="text" name="b1" id="b1"> the % i want to update*/


$add=($a+$b);

$sql = "UPDATE mem SET balance = balance +'$add'";  


if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }

 

This obviously does not work but it could possibly give you a better understanding of maybe what im trying to do here. Any help would be appreciated.

 

Thanks

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.