Jump to content

PHP script Request.


seany123

Recommended Posts

basically what im wanting is for certain values in my database to be increased by a certain percent...

 

In a Table called 'players'

I want;

a value called 'Energy' to be increased by 25% of 'maxenergy'.

a value called 'nerve' to be increased by 25% of 'maxnerve'.

a value called 'awake' to go up by +5

a value called 'hp' to be increased by 25% of 'maxhp'

 

can this be done?

Link to comment
https://forums.phpfreaks.com/topic/124236-php-script-request/
Share on other sites

In a Table called 'players'

I want;

a value called 'Energy' to be increased by 25% of 'maxenergy'.

a value called 'nerve' to be increased by 25% of 'maxnerve'.

a value called 'awake' to go up by +5

a value called 'hp' to be increased by 25% of 'maxhp'

 

//Code for connecting to database.

//First we need to get the values of maxenergy, maxnerve, maxhp
$row = mysql_fetch_array(mysql_query("SELECT * FROM players WHERE !!!Insert data to select which user you want!!!"));
$maxenergy = $row['maxenergy'];
$maxnerve = $row['maxnerve'];
$maxhp = $row['maxhp'];
//Get 25% of each of these values.
$energy_add = 0.25*$maxenergy;
$nerve_add = 0.25*$maxnerve;
$hp_add = 0.25*$maxhp;
//Update the table
mysql_query("UPDATE players SET energy=energy+$energy_add, nerve=nerve+$nerve_add, hp=hp+$hp_add WHERE !!!Insert data to select which user you want!!!");

 

Hope that helps.

Link to comment
https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641758
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.