joecooper Posted May 6, 2008 Share Posted May 6, 2008 How can i have a random number which is + / - 10 from the last number. (every time the script is run it will put the number into a mysql table). But if the number is above 100, wont go any higher. Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/ Share on other sites More sharing options...
947740 Posted May 6, 2008 Share Posted May 6, 2008 Specify the maximum and minimum random numbers: rand($min,$max); Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/#findComment-534422 Share on other sites More sharing options...
ILYAS415 Posted May 6, 2008 Share Posted May 6, 2008 ummmm... presuming i know what you mean.... <? $lastnumber= 20; //just for an example $newnumber= rand($lastnumber-10, $lastnumber+10); if ($newnumber > 10){ $newnumber= $lastnumber-10; }else{ } mysql_query("UPDATE number SET lastnumber='$newnumber' WHERE lastnumber='$lastnumber'"); ?> Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/#findComment-534425 Share on other sites More sharing options...
joecooper Posted May 6, 2008 Author Share Posted May 6, 2008 yes thats what i mean. Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/#findComment-534428 Share on other sites More sharing options...
ILYAS415 Posted May 6, 2008 Share Posted May 6, 2008 is it working? Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/#findComment-534432 Share on other sites More sharing options...
joecooper Posted May 6, 2008 Author Share Posted May 6, 2008 not tested but i assume so Link to comment https://forums.phpfreaks.com/topic/104393-random-numbers/#findComment-534526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.