mrjonnytou Posted August 18, 2008 Share Posted August 18, 2008 I have a query which i extract a value (Integer) from. I would like to take this number and increment it by 0.1. Any guidance would be appreciated. Do I need to change the datatype in the database table or something??? <?php $new_number = $number + 0.1; ?> ...??? Link to comment https://forums.phpfreaks.com/topic/120162-incrementing-numbers-help/ Share on other sites More sharing options...
Mchl Posted August 18, 2008 Share Posted August 18, 2008 $number += 0.1; Link to comment https://forums.phpfreaks.com/topic/120162-incrementing-numbers-help/#findComment-619061 Share on other sites More sharing options...
trq Posted August 18, 2008 Share Posted August 18, 2008 Are you saying you want to increment them within the database? Then you would need store your numbers as floats not ints. Otherwise, the code you have posted works fine in php. <?php $i = 1; $x += 0.1; echo $x . "\n"; ?> Link to comment https://forums.phpfreaks.com/topic/120162-incrementing-numbers-help/#findComment-619062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.