I have several segments of data values in the database.
If I assume they together make 100% how do I show each one as a percentage value?
Run a query to get a SUM of all of them, then run another query to get each one (or the one you want) and simply do a little division to between the sum and the current row to get the percentage. You can find SUM in the mysql manual.
Yes, I can ADD THE TOTAL SUM, I'm a bit confused on how to do the math for each one. Say I want to display them all on the same page and show what percentage each one is.
$result = mysql_query("some sql here to get all of them"); while( $row = mysql_fetch_array($result) ) { echo("$row[name]'s percentage is " . ( $row[value]/$sum ) . "%."); }