burtybob Posted November 11, 2007 Share Posted November 11, 2007 $num=mysql_query("SELECT * FROM members") or die (mysql_error()); $num=mysql_num_rows($num) or die (mysql_error()); $useridabc=0; while ($num>$useridabc) { $money="90,000,000"; $sql=mysql_query("SELECT * FROM members WHERE `userid`='$useridabc' AND `money`>'$money'") or die (mysql_error()); $sql=mysql_fetch_array($sql) or die(mysql_error()); $moneyaftertax=$sql[money]; $moneyaftertax=($moneyaftertax*0.99); $sql2=mysql_query("UPDATE members SET `money`='$moneyaftertax' WHERE `userid`='$useridabc'"); $useridabc++; Ok as far as i got is it either takes ALL the money or else it does the *0.99 all the time for all users even if they have less than 9mill. I know that the $money is currently set to 90mill this is because i was testing to see if that made any difference however it did not i have tried all that i can think if so now i have come to the best place for php help Thanks in advance burtybob Quote Link to comment https://forums.phpfreaks.com/topic/76847-solved-select-from-where-money-is-more-than-9mill/ Share on other sites More sharing options...
redbullmarky Posted November 11, 2007 Share Posted November 11, 2007 i might be wrong, but try removing the commas (and your quotes?) in your $money = "90,000,000"; line - only actual digits and a decimal point/negative - are valid in a number when used in this context, else it's classed as a string. you can use money_format() or similar to display the number to the user "properly" on the page, but for the sake of comparisons, etc - a string wont work. Quote Link to comment https://forums.phpfreaks.com/topic/76847-solved-select-from-where-money-is-more-than-9mill/#findComment-389054 Share on other sites More sharing options...
burtybob Posted November 11, 2007 Author Share Posted November 11, 2007 ok i tried that but that didnt work and it just brought up a blank page (errors are on) and when i went back to the with quotes and commas blank page??? still no idea as have tried it on localhost to the same problem as well as my webhost Quote Link to comment https://forums.phpfreaks.com/topic/76847-solved-select-from-where-money-is-more-than-9mill/#findComment-389058 Share on other sites More sharing options...
PHP_PhREEEk Posted November 11, 2007 Share Posted November 11, 2007 dunno about the money thing... I'm just trying to grip the database pull logic here. So you select ALL members, and figure out how many that is. Then, starting at 0, you move through each account's ID to the maximum account ID number. For each ID, you ask for a new set of data using ID tied to money > $money. This seems like such overkill... would this not do the same thing? $money = '90000000'; $sql = "SELECT `userid`, `money` FROM `members` WHERE `money` > '$money'"; if ( !$result = mysql_query($sql) ) { die('Database error: ' . mysql_error()); } WHILE ( $row = mysql_fetch_assoc($result) ) { $moneyaftertax = intval($row['money']); $moneyaftertax = $moneyaftertax*.99; $sql2 = "UPDATE `members` SET `money` = '$moneyaftertax' WHERE `userid` = '{$row['userid']}' if ( !$result2 = mysql_query($sql2) ) { die('Database error: ' . mysql_error()); } } Quote Link to comment https://forums.phpfreaks.com/topic/76847-solved-select-from-where-money-is-more-than-9mill/#findComment-389065 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.