V vien3211 Eternal Poster Established Joined Aug 9, 2016 Posts 829 Reaction 73 Points 313 Dec 6, 2022 #1 Pakitulungan naman po ako. Number 1 letter B and C po sana. Thank you! Attachments You do not have permission to view the full content of this post. Log in or register now.
F FinestWork Honorary Poster Dec 7, 2022 #2 Pa-post po ng code mo para matulungan ka namin kung saan hindi nag-wo-work.
M Migfus Eternal Poster Established Dec 7, 2022 #3 Madali naman yan, e research mo nalang kung anong functions sa array.
I iannejay27 Eternal Poster Dec 7, 2022 #4 pwede ba makita yung structure mo ng Array dun sa 1.A yun kasi yung magiging base para dun sa B and C
pwede ba makita yung structure mo ng Array dun sa 1.A yun kasi yung magiging base para dun sa B and C
D derksd Grasshopper Dec 8, 2022 #5 vien3211 Eto lods check mu You do not have permission to view the full content of this post. Log in or register now. PHP: <table style="border: 1px solid black;"> <thead > <tr> <th>Precint</th> <th>Candidate A</th> <th>Candidate B</th> <th>Candidate C</th> <th>Candidate D</th> </tr> </thead> <tbody> <?php $results = array ( array(192,147,186,114,267), array(48,90,12,21,13), array(206,312,121,408,382), array(37,21,38,39,29), ); for ($col = 0; $col < 5; $col++) { echo "<tr><td>" . $col+1 . "</td>"; for ($row = 0; $row < 4; $row++) { echo "<td>" . $results[$row][$col] . "</td> "; } echo "</tr>"; } ?> </tbody> </table> <br> <table style="border: 1px solid black;"> <thead> <tr> <th>Candidate</th> <th>Total</th> <th>Percentage</th> </tr> </thead> <tbody> <?php $totalCandidates = count($results); $candidates = array("A","B","C","D"); $total = array(); $percentage = array(); $winner = null; for ($i=0; $i < $totalCandidates; $i++) { $total[$i] = array_sum($results[$i]); } $grandTotal = array_sum($total); for ($i=0; $i < $totalCandidates; $i++) { $percentage[$i] = round($total[$i] / $grandTotal * 100); echo "<tr><td>" . $candidates[$i] . "</td>"; echo "<td>" . $total[$i] . "</td>"; echo "<td>" . $percentage[$i] . "%</td></tr>"; if ($percentage[$i] > 50 ) $winner = $i; } ?> </tbody> </table> <?php echo "<br>" . "Candidate " . $candidates[$winner] . " with the " . $percentage[$winner] . "% total votes is the winner."; ?>
vien3211 Eto lods check mu You do not have permission to view the full content of this post. Log in or register now. PHP: <table style="border: 1px solid black;"> <thead > <tr> <th>Precint</th> <th>Candidate A</th> <th>Candidate B</th> <th>Candidate C</th> <th>Candidate D</th> </tr> </thead> <tbody> <?php $results = array ( array(192,147,186,114,267), array(48,90,12,21,13), array(206,312,121,408,382), array(37,21,38,39,29), ); for ($col = 0; $col < 5; $col++) { echo "<tr><td>" . $col+1 . "</td>"; for ($row = 0; $row < 4; $row++) { echo "<td>" . $results[$row][$col] . "</td> "; } echo "</tr>"; } ?> </tbody> </table> <br> <table style="border: 1px solid black;"> <thead> <tr> <th>Candidate</th> <th>Total</th> <th>Percentage</th> </tr> </thead> <tbody> <?php $totalCandidates = count($results); $candidates = array("A","B","C","D"); $total = array(); $percentage = array(); $winner = null; for ($i=0; $i < $totalCandidates; $i++) { $total[$i] = array_sum($results[$i]); } $grandTotal = array_sum($total); for ($i=0; $i < $totalCandidates; $i++) { $percentage[$i] = round($total[$i] / $grandTotal * 100); echo "<tr><td>" . $candidates[$i] . "</td>"; echo "<td>" . $total[$i] . "</td>"; echo "<td>" . $percentage[$i] . "%</td></tr>"; if ($percentage[$i] > 50 ) $winner = $i; } ?> </tbody> </table> <?php echo "<br>" . "Candidate " . $candidates[$winner] . " with the " . $percentage[$winner] . "% total votes is the winner."; ?>