linlymz,
I don't think your suggestion is going to work. one your percentage result will be a decimal and needs to be multiplied by 100, also no need to run the first query and loop through all the results, this should be a bit more efficient and it results in real numbers.
PHP Code:
<?
$db = mysql_connect("localhost", "", "");
mysql_select_db("test");
$countsql = mysql_query("SELECT SUM(votes) as totalvotes from votes") or DIE(mysql_error());
$totalvotes = mysql_result($countsql, 0);
?>
<br>
<?
$result = mysql_query("SELECT ID, value, votes, (votes/$totalvotes) as totalnum from votes");
while($row = mysql_fetch_array($result)) {
extract($row);
print "$ID - $value - $votes - ".floor(($totalnum * 100))."<br>";
}
?>
Bookmarks