protected function searchresultedit() { global $user; global $objPDO; $search = $_POST['search_input']; require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/student_profile_class.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/cloud/model/parent_class.php'; $studentProfile = new StudentProfile($objPDO); if ($search != '') { $roll_match = $studentProfile->SearchByRollNo($search); $admission_match = $studentProfile->SearchByAdmissionNumber($search); $name_match = $studentProfile->SearchByName($search); $class_match = $studentProfile->SearchByClass($search); echo '<div class="results"><span style="font-family:tahoma; font-weight:bold;font-size:15px">Displaying Search Results for "'; echo $search; echo '"</span></div>'; //start of roll no search $i = 0; echo '<div class="roll_search">'; for ($i = 0; $i < count($roll_match); $i++) { if ($i == 0) { echo '<div class="search_heading">Roll Number Matches</div>'; echo '<table class="search_result"><tr class="search_head"><td>Admission Number</td><td>Roll Number</td><td>Name</td><td>Class</td><td>View</td></tr>'; } if ($i % 2 == 0) { echo '<tr>'; } else { echo '<tr class="search_result_item">'; } $start = stripos($roll_match[$i]['roll_no'], $search); $end = $start + strlen($search) - 1; $block = $roll_match[$i]['roll_no']; $highlighted = substr($block, 0, $start) . '<span class="search_highlight">' . substr($block, $start, strlen($search)) . '</span>' . substr($block, $end + 1); echo '<td>' . $roll_match[$i]['admission_number'] . '</td>'; echo '<td>' . $highlighted . '</td>'; echo '<td>' . $roll_match[$i]['name'] . '</td>'; echo '<td>' . $roll_match[$i]['class_level'] . '</td>'; echo '<td><a class="link" href="http://localhost/cloud/studentprofile/confirm/' . $roll_match[$i]['user_id'] . '">Edit Profile</a></td>'; echo '</tr>'; } echo '</table></div>'; //end of roll no search //start of admission no search $i = 0; echo '<div class="admission_search">'; for ($i = 0; $i < count($admission_match); $i++) { if ($i == 0) { echo '<div class="search_heading">Admission Number Matches</div>'; echo '<table class="search_result"><tr class="search_head"><td>Admission Number</td><td>Roll Number</td><td>Name</td><td>Class</td><td>View</td></tr>'; } if ($i % 2 == 0) { echo '<tr>'; } else { echo '<tr class="search_result_item">'; } $start = stripos($admission_match[$i]['admission_number'], $search); $end = $start + strlen($search) - 1; $block = $admission_match[$i]['admission_number']; $highlighted = substr($block, 0, $start) . '<span class="search_highlight">' . substr($block, $start, strlen($search)) . '</span>' . substr($block, $end + 1); echo '<td>' . $highlighted . '</td>'; echo '<td>' . $admission_match[$i]['roll_no'] . '</td>'; echo '<td>' . $admission_match[$i]['name'] . '</td>'; echo '<td>' . $admission_match[$i]['class_level'] . '</td>'; echo '<td><a class="link" href="http://localhost/cloud/studentprofile/confirm/' . $admission_match[$i]['user_id'] . '">Edit Profile</a></td>'; echo '</tr>'; } echo '</table></div>'; //end of admission no search //start of name search $i = 0; echo '<div class="name_search">'; for ($i = 0; $i < count($name_match); $i++) { if ($i == 0) { echo '<div class="search_heading">Student Name Matches</div>'; echo '<table class="search_result"><tr class="search_head"><td>Admission Number</td><td>Roll Number</td><td>Name</td><td>Class</td><td>View</td></tr>'; } if ($i % 2 == 0) { echo '<tr>'; } else { echo '<tr class="search_result_item">'; } $start = stripos($name_match[$i]['name'], $search); $end = $start + strlen($search) - 1; $block = $name_match[$i]['name']; $highlighted = substr($block, 0, $start) . '<span class="search_highlight">' . substr($block, $start, strlen($search)) . '</span>' . substr($block, $end + 1); echo '<td>' . $name_match[$i]['admission_number'] . '</td>'; echo '<td>' . $name_match[$i]['roll_no'] . '</td>'; echo '<td>' . $highlighted . '</td>'; echo '<td>' . $name_match[$i]['class_level'] . '</td>'; echo '<td><a class="link" href="http://localhost/cloud/studentprofile/confirm/' . $name_match[$i]['user_id'] . '">Edit Profile</a></td>'; echo '</tr>'; } echo '</table></div>'; //end of name search //start of class search $i = 0; echo '<div class="class_search">'; for ($i = 0; $i < count($class_match); $i++) { if ($i == 0) { echo '<div class="search_heading">Class Matches</div>'; echo '<table class="search_result"><tr class="search_head"><td>Admission Number</td><td>Roll Number</td><td>Name</td><td>Class</td><td>View</td></tr>'; } if ($i % 2 == 0) { echo '<tr>'; } else { echo '<tr class="search_result_item">'; } $start = stripos($class_match[$i]['class_level'], $search); $end = $start + strlen($search) - 1; $block = $class_match[$i]['class_level']; $highlighted = substr($block, 0, $start) . '<span class="search_highlight">' . substr($block, $start, strlen($search)) . '</span>' . substr($block, $end + 1); echo '<td>' . $class_match[$i]['admission_number'] . '</td>'; echo '<td>' . $class_match[$i]['roll_no'] . '</td>'; echo '<td>' . $class_match[$i]['name'] . '</td>'; echo '<td>' . $highlighted . '</td>'; echo '<td><a class="link" href="http://localhost/cloud/studentprofile/confirm/' . $class_match[$i]['user_id'] . '">Edit Profile</a></td>'; echo '</tr>'; } echo '</table></div>'; //end of roll no search } }