kpetsche20 Posted February 21, 2008 Share Posted February 21, 2008 I'm trying to get the total of $row['value']. This code just gives me a weird number. ?php $resultID = @mysql_query("SELECT * FROM `user_banking` WHERE `referral` = '$_SESSION[id]'", $linkID); for ($x= 0; $x < mysql_num_rows($resultID); $x++) { $row = mysql_fetch_array($resultID); $cur_bal = ""; $cur_bal = $cur_bal + $row['value']; echo $cur_bal; print "<tr><td width=\"192\" class=\"myaccount\">$$row[value]</td> <td width=\"193\" class=\"myaccount\">$row[from]</td> <td width=\"193\" class=\"myaccount\"> $row[referral]</td> </tr>\n"; } ?> Quote Link to comment Share on other sites More sharing options...
vbnullchar Posted February 21, 2008 Share Posted February 21, 2008 whats the output? you have two dollar signs in $row[value] print "<tr><td width=\"192\" class=\"myaccount\">$$row[value]</td> Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted February 21, 2008 Author Share Posted February 21, 2008 The code currently shows up where I try to add the rows 0.650.5 Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted February 21, 2008 Author Share Posted February 21, 2008 whats the output? you have two dollar signs in $row[value] print "<tr><td width=\"192\" class=\"myaccount\">$$row[value]</td> The dollar sign is there to display a users balance in USD. Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted February 21, 2008 Share Posted February 21, 2008 Might be better off doing something like this then print "<tr><td width=\"192\" class=\"myaccount\">$" .$row[value] ."</td> <td width=\"193\" class=\"myaccount\">" .$row[from] ."</td> <td width=\"193\" class=\"myaccount\"> " .$row[referral] ."</td> </tr>\n"; Quote Link to comment Share on other sites More sharing options...
kpetsche20 Posted February 21, 2008 Author Share Posted February 21, 2008 That didn't change anything. You can view the out put by going to thotis.com and logging in as demouser / demo. Once logged in go to http://www.thotis.com/members/index.php?p=hey Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted February 21, 2008 Share Posted February 21, 2008 I just noticed that you are using your variables as strings. make sure you declare your $cur_bal = 0; no quotes BEFORE you enter the for loop. otherwise it just clears the variable every time you run a iteration of the loop then echos the value... the output you are seeing makes perfect sense. Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted February 21, 2008 Share Posted February 21, 2008 Try This code: <?php $resultID = @mysql_query("SELECT * FROM `user_banking` WHERE `referral` = '$_SESSION[id]'", $linkID); $cur_bal = 0; for ($x= 0; $x < mysql_num_rows($resultID); $x++) { $row = mysql_fetch_array($resultID); $cur_bal += $row['value']; echo $cur_bal; print "<tr><td width=\"192\" class=\"myaccount\">$" .$row[value] ."</td> <td width=\"193\" class=\"myaccount\">" .$row[from] ."</td> <td width=\"193\" class=\"myaccount\"> " .$row[referral] ."</td> </tr>\n"; } ?> Quote Link to comment 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.