$contestants_id[$i] = $result1[$i]["contestant_id"]; $picture_names[$i] = $images_dir . $result1[$i]["picture_name"]; $contestants_user_ids[$i] = $result1[$i]["user_id"]; $contestants_post_id[$i] = $result1[$i]["post_id"]; } } else { echo ""; } $contestant_list = ""; $allPosts = getAllPosts($election_id_here); //for each post,get contestant $postCon = $contestants_array = $string_result_array = array(); $superIndex = array(); $image_dir = "../images/contestants/"; for ($i = 0; $i < count($allPosts); $i++) { $postCon[$allPosts[$i]['post']] = getAllContestants($allPosts[$i]['post_id']); array_push($superIndex, $allPosts[$i]['post']); } //Store the contestants pictures in contestant_list array for ($japhet = 0; $japhet < count($postCon); $japhet++) { $post_name = $superIndex[$japhet]; if (!empty($postCon[$post_name])) { for ($length = 0; $length < count($postCon[$post_name]); $length++) { $display = $postCon[$post_name][$length]; //$display holds a contestant detail $key = wrap($display['user_id']); $image = $image_dir . $display['picture_name']; $contestant_list = "<div class='col-md-4' >" . "<div class='img'>" . "<img src=" . $image . " width=100% height=200px alt=" . contestantName($display['user_id']) . ">"; $contestant_list .= "<div class='desc'><b style='text-align:center;'>" . contestantName($display['user_id']) . "</b><br><small> " . $post_name . "</small></div>" . "<div onclick='contestants({$key})' class='view-profile'><button onclick='contestants({$key})' class='btn btn-default'>View Profile</button></div>"; $contestant_list .= "</div></div>"; array_push($contestants_array, $contestant_list);
//determining when to make the view profile link visible or not' $checkContestant1 = checkContestant(user_id($myemail), $election_id); if (!empty($checkContestant1)) { $profile1 = "<a href='viewprofile.php' class='active'>View Profile</a>"; } else { $profile1 = ""; } //get post table $all_posts = getAllPosts($election_id); $total_contestants = 0; $posts_table = '<div class="table-responsive contestants_table" style="max-height: 220px"> <table class="table table-striped"> <thead > <tr> <th>Post</th> <th>Pin</th> <th>Number of Contestants</th> </tr> </thead> <tbody>'; for ($i = 0; $i < count($all_posts); $i++) { $posts_table .= '<tr> <td>' . $all_posts[$i]["post"] . '</td> <td>' . $all_posts[$i]["post_key"] . '</td> <td>' . count(getAllContestants($all_posts[$i]["post_id"])) . '</td> </tr>'; $total_contestants += count(getAllContestants($all_posts[$i]["post_id"])); } $posts_table .= '</tbody> </table> </div>';