Hello and good day. I want to know how to build php code to select and display student record. For now i success with select student id and display all one row student record. But how to get multiple record with same name.
pid name subject
1 Amy MATH
2 Amy ELT
3 John BI
4 John BM
5 Smith MATH
6 Smith ENGLISH
for now it will display only one row data if search.
pid name subject
1 Amy MATH
I want it display all Amy record.
pid name subject
1 Amy MATH
2 Amy ELT
Here my php code:
<?php /* * Following code will list all the products */ // array for JSON response $response = array(); // include db connect class require_once __DIR__ . '/db_connect.php'; // connecting to db $db = new DB_CONNECT(); //here the search value is what you send from the app if(isset($_GET["matricID"])){ $string_input = $_GET['matricID']; $result = mysql_query("SELECT * FROM tbl_semester WHERE matricID = '".$string_input."'") or die(mysql_error()); //$result = mysql_query("SELECT * FROM tbl_semester GROUP BY matricID ") or die(mysql_error()); } // check for empty result if (mysql_num_rows($result)>0) { while ($column = mysql_fetch_array($result)){ // temp user array // looping through all results $response["tbl_semester"] = array(); $semester = array(); $semester["pid"] = $column["pid"]; $semester["matricID"] = $column["matricID"]; $semester["code"] = $column["code"]; $semester["course"] = $column["course"]; $semester["point"] = $column["point"]; $semester["crdhour"] = $column["crdhour"]; $semester["grdpoint"] = $column["grdpoint"]; $semester["reattempt"] = $column["reattempt"]; $semester["grd"] = $column["grd"]; // push single product into final response array array_push($response["tbl_semester"], $semester); } // success $response["success"] = 1; // echoing JSON response echo json_encode($response); } else { // no products found $response["success"] = 0; $response["message"] = "No products found"; // echo no users JSON echo json_encode($response); } ?>