I'm creating a table with PHP/MySql to enter local election results from my newspaper, I'm not a professional developer, more of just a hobbiest hack (who hasn't worked with PHP for a few years either), so feel free to correct existing code if you so please.
What I want to do is to list vote totals for each precinct, and then have PHP total those totals.
So, the way the data base would be set up is Race ID, Candidate Name, and each available precinct's totals.
This is my current code to return one of the tables. What I would need to do is set up several calculations, one for each candidate, and then be able to show a total at the end of the row on the table. If percent of vote is not too much more difficult, I'd like to do that to, but I'm wiling to stop at vote total if it's much more of a headache.
<div class="racestyle">
<h4>Centerville - Mayor</h4>
<table class="results">
<tr><td class='candidate'>Name</td><td class='numbers'>Ward 1</td><td class='numbers'>Ward 2</td><td class='numbers'>Ward 3</td><td class='numbers'>Absentee</td><td class='numbers'>Total</td></tr>
<?php
// Connects to your Database
mysql_connect("SERVER", "USER", "PASS") or die(mysql_error());
mysql_select_db("DATABASE") or die(mysql_error());
$data = mysql_query("SELECT * FROM `13results` WHERE `Race` = 'CVmayor'")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "<tr><td class='candidate'>".$info['Name'] . "</td><td class='numbers'>".$info['Ward1'] . "</td><td class='numbers'>".$info['Ward2'] . "</td><td class='numbers'>".$info['Ward3'] . "</td><td class='numbers'>".$info['Absentee'] . "</td><td class='numbers'>TOTALHERE</td></tr>";
}
?>
</table>
</div>