Change data in the table in a random way

I once asked how to choose an identifier in a random way, everything worked out for me and I was advised to read about randomness Here. And now I need to change the data in this way, and I decided to go to that site, and the effect was as follows: I look in the book and see a figure. Tell me how to remake this:

mysql_query("UPDATE `startpoke` SET `all_life`=`all_life`+4 WHERE id_poke='".$_SESSION['id']."'")or die(mysql_error()) ;

That’s it, it’s part of

SET `all_life`=`all_life`+4

Added life from 2 to 5 , For example

SET `all_life`=`all_life`+  2  5

Thanks in advance!


Answer 1, authority 100%

The request should be like this:

UPDATE startpoke SET all_life = all_life + 2 + ROUND(RAND() * 3) WHERE id_poke = ?

That is:

mysql_query("UPDATE `startpoke` SET `all_life`=`all_life` + 2 + ROUND(RAND() * 3) WHERE id_poke='".$_SESSION['id']."'")
or die(mysql_error()) ;

Answer 2

mysql_query("UPDATE `startpoke` SET `all_life`=`all_life`+rand(2,5) WHERE id_poke='".$_SESSION['id']."'")or die(mysql_error()) ;