function createOverviewTableForCategory($category_id) { global $variables; $table = $variables['categoriesTableName']; $query = "SELECT * FROM {$table} WHERE {$variables['category_id_categories']} = {$category_id}"; $result = mysql_query($query) or die(" Find createOverviewTableForCategory query Failed!" . mysql_error()); $category = mysql_fetch_array($result); $text = "<table class='overviewOuter'>"; $text .= createDistrictMachineHeader($category['category_name']); //get each candidate $candidates = getCandidates($category_id); while ($candidate = mysql_fetch_array($candidates)) { $text .= "<tr><td class='overviewNoWrap'>{$candidate['candidate_name']}</td>"; //TODO get machines and districts //data entered $machineArray = getArrayOfMachines(); foreach ($machineArray as $machineInfo) { $district = $machineInfo[0]; $machine = $machineInfo[1]; $text .= "<td class='overview'>"; $text .= getElectionResults($district, $machine, $candidate['candidate_id']); $text .= "</td>"; } $text .= "</tr>"; } //get votes for each cell $text .= "</table>"; return $text; }
function createOverviewTableForCategory($category_id) { global $variables; global $conn; $table = $variables['categoriesTableName']; $query = "SELECT * FROM {$table} WHERE id = {$category_id}"; $result = runQuery($query); $category = $result->fetch_assoc(); //mysql_fetch_array($result); $text = "<table class='overviewOuter' id='table1'>"; $text .= createDistrictMachineHeader($category['question']); //election id $election_id = getCurrentElectionID(); //get each candidate $candidates = getCandidates($category_id); while ($candidate = $candidates->fetch_assoc()) { //mysql_fetch_array($candidates)){ $text .= "<tr><td class='overviewNoWrap'>{$candidate['response']}</td>"; // get machines and districts $machineArray = getArrayOfMachinesForElection($election_id); foreach ($machineArray as $machineInfo) { $district = $machineInfo[0]; //echo "District $district <br>"; $machine = $machineInfo[1]; $text .= "<td class='tally'>"; $text .= getElectionResults($district, $machine, $candidate['id']); $text .= "</td>"; } $text .= "<td class='tally'>" . getTotalTally($category_id, $candidate['response'], $election_id) . "</td>"; $text .= "</tr>"; } /* if(is_numeric(stripos($category['question'], "Machine"))){ $text .= createDistrictVotesRow($category_id); $text .= createRegisteredVotersRow($category_id); $text .= createPercentageRow($category_id); } */ $text .= createMachineSumRow($category_id); $text .= createDistrictVotesRow($category_id); $text .= createRegisteredVotersRow($category_id); $text .= createPercentageRow($category_id); $text .= "</table>"; return $text; }