This is a simple program that pulls all the records from a table called STUDENTS.

connect_error) { die("Connection failed: " . $conn->connect_error); } //echo "Connected successfully
"; $sql = "SELECT id, name, dept_name FROM student"; //This sql statement uses the asterisk wildcard that brings back all fields //$sql = "SELECT * FROM student"; $result = $conn->query($sql); //This will show you if you've gotten any records back from the database //echo "Total Records found:".$result->num_rows."
"; if ($result->num_rows > 0) { // output data of each row by using a loop in PHP while($row = $result->fetch_assoc()) { echo "Student ID: " . $row["id"]. " - Name: " . $row["name"]. " Department:" . $row["dept_name"]. "
"; //this just shows the displaying of the row data without the long labels //echo $row["id"]. " - " . $row["name"]. " - " . $row["dept_name"]. "
"; // use this statement if you are going to use SELECT * FROM STUDENTS //echo "Student ID: " . $row["id"]. " - Name: " . $row["name"]. " Department:" . $row["dept_name"]."Total Credit".$row["tot_cred"]. "
"; } } else { echo "0 results"; } $conn->close(); ?>