I'm trying to figure this out. I want to be able to print out the total amount of "points" for a specific user depending on rows from a db table. I have an idea that I should get all the records from the user into an array and add the numbers here? $result = mysql_query("SELECT * FROM ".$prefix."_numbers WHERE userid=$clubuser") or exit(mysql_error()); while($row = mysql_fetch_array($result)){ Some array and output here? } PHP: Please help
When possible, let the database handle simple calculations and filter results for you. This minimizes the amount of data your database (server) needs to send to your website (server). You may be able to simply change your SQL query to something like this: SELECT SUM(points) as total FROM mytable WHERE something=somethingelse Code (markup): Such a query will return a single result row with a single "column" called "total". No array needed here.
There are many security vulnerabilities in the code fragment you posted. Before you allow access to your script or website, be sure to learn about avoiding MySQL injection vulnerabilities and other security concerns when developing PHP applications.