seany123 Posted September 14, 2008 Share Posted September 14, 2008 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 More sharing options...
MasterACE14 Posted September 14, 2008 Share Posted September 14, 2008 yes, but do you want this to happen within a query? or are you using the data dynamically with PHP? if its a query: just use mysql_query("UPDATE etc etc"); otherwise just work with PHP variables or however your using it. Link to comment https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641538 Share on other sites More sharing options...
seany123 Posted September 14, 2008 Author Share Posted September 14, 2008 data dynamically with PHP if i just let you know exactly what i need this for... im making a game and the above values are things the players all have. so im need a script that will update all the players values (in the players table) Link to comment https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641543 Share on other sites More sharing options...
seany123 Posted September 14, 2008 Author Share Posted September 14, 2008 Can anyone give me a hand, i dont know if this helps anymore but im using: adodb php libary Link to comment https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641562 Share on other sites More sharing options...
kenrbnsn Posted September 15, 2008 Share Posted September 15, 2008 We don't write scripts for you in this forum. We help you with scripts you've already written and are having problems. If you want someone to write a script for you, please post in the Freelancing area. Ken Link to comment https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641674 Share on other sites More sharing options...
jamesbrauman Posted September 15, 2008 Share Posted September 15, 2008 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 More sharing options...
seany123 Posted September 15, 2008 Author Share Posted September 15, 2008 okay yeah that helps alot but i dont want to just update 1 users table i want to update everyones. Link to comment https://forums.phpfreaks.com/topic/124236-php-script-request/#findComment-641782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.