Jump to content

Tovin

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Tovin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. There isn't any. I'm just wondering how I would go about adding all the numbers from one column together.
  2. This is probably really easy but I can't figure it out. I have a column and the only data in it is numbers. What do I do to add all of these numbers together and create a variable out of the total?
  3. Thank you so much! Exactly what I needed.
  4. Alright, I've written a script with an IF and ELSE statement and I was wondering if there was a way to make two IF variables. What I'm trying to get my script to do is this: Read two columns and if either of those are true then echo one thing or else echo something different. Is there some sort of OR statement? if ( $variable1 == 0 or $variable2 == 10) { echo "blah here."; } else { echo "other stuff."; } I hope that makes sense. I know that the code above doesn't work, I was just wondering how to make it. Thanks!
  5. Ohh. So I see. lol! Thank you SO much for your help.
  6. Ha! That did it! You're awesome! $myusername was defined by the sessions. So the problem was that I wasn't specifying what row to pull the $points data from?
  7. Hey! It handily printed out the number of results it found (17) but the table still did not get updated.
  8. Still nothin'. Would the problem be maybe that it's pulling data from the same table it's supposed to update?
  9. Sorry, will use code tags in the future. Tried Wesf90's method and it's doing absolutely nothing to the table. $myusername is being pulled from somewhere else. It hasn't been causing the problem.
  10. mysql_connect("host","username","password"); mysql_select_db("db"); $result = mysql_query("select * from table"); while($r=mysql_fetch_assoc($result)) { $points=$r['points']; $plus = '6'; $total = $points + $plus; $sql = "UPDATE table SET points = '$total' WHERE username = '$myusername'"; mysql_query($sql) or die(mysql_error()); }
  11. Alright, thank you, that worked a little bit. It's still, however, not reading the $points variable. When I change this line: $points=$r['points'] ; to $points='6'; it works just fine, updating the table and everything. But left with the $r['points'] in there, the $points variable isn't working correctly. Suggestions?
  12. Alright....it's still being frustrating. The script appears to run just fine only it's not adding for some reason. When I echo $total at the bottom of the page it gives me the total I already started with. For example, I start with 22 points. I'm trying to add 6 points to this so $total should equal 28, right? Apparently not. lol. It's still showing 22 and it's still not updating the table. So for some reason $total is reading just the $points and not $plus? Thanks for the help so far!
  13. Alright, so I'm fairly new to PHP (and to this forum) so this code is very simple. But for some reason I can't get it to work. What I'm trying to do, basically, is take a variable from a table, use it in an equation and place the results of the equation back into the table. Like so: while($r=mysql_fetch_array($result)) { $points=$r["points"]; $plus = '6'; $total = $points + $plus; $sql = "UPDATE table SET points = '$total' WHERE username = '$myusername'"; } It works...once. I'll change $plus to be something and rerun the script and usually it will update but NEVER to what I expected or wanted. Last night 16 + 2 suddenly equalled 15? I'm really not quite sure what I did wrong. lol. It's probably something extremely simple, I'm just not seeing it due to my inexperience. Any help will be appreciated. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.