Skip to content

Commit 3ed4dfd

Browse files
committed
Remove get_candidates() function from candidates.php
1 parent 685ba96 commit 3ed4dfd

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

admin/candidates.php

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
<?php
22
$auth_required = true;
33
require_once("../config.php");
4-
5-
function get_candidates() {
6-
global $DB;
7-
$query = mysqli_prepare($DB, "SELECT id, name FROM `candidates`");
8-
mysqli_stmt_execute($query);
9-
mysqli_stmt_bind_result($query, $id, $name);
10-
mysqli_stmt_store_result($query);
11-
$results = array();
12-
while(mysqli_stmt_fetch($query)){
13-
$results[$id] = $name;
14-
}
15-
return $results;
16-
}
17-
4+
185
$htmlOutput = "";
19-
6+
207
$htmlOutput .= "<h1>Candidates</h1>";
218
$candidates = get_candidates();
229
if ( count($candidates) != 0 ) {
@@ -29,15 +16,15 @@ function get_candidates() {
2916
else {
3017
$htmlOutput .= "None<br>";
3118
}
32-
19+
3320
$htmlOutput .= "<br><hr><br>";
3421
$htmlOutput .= "<h3>Add a candidate</h3>";
3522
$htmlOutput .= "<form action='add_candidate.php' method='post' autocomplete='off'>
3623
Name <input type='text' name='candidate_name' required><br>
3724
<input class='btn' type='submit' value='Add Candidate'>";
38-
25+
3926
$htmlOutput .= "<script>document.body.onload=function(){document.getElementsByName('candidate_name')[0].focus()}</script>";
40-
27+
4128
$htmlOutput .= "<br><br><br><br><a class='btn btn-green' href='".$base_url."admin/'>Go to Allow Voting</a>";
42-
29+
4330
include("../template.php");

0 commit comments

Comments
 (0)