setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //prepare the SELECT statement to choose all employees $employees = $conn->prepare("SELECT * FROM employee"); //execute the SELECT statement $employees->execute(); //display all the records from the employees table in a table format. echo "

Display all employee records

"; echo ""; echo ""; //print out the Emp_No heading echo ""; //print out the Emp_fname heading echo ""; //print out the Emp_sname heading echo ""; //print out the Grade heading echo ""; echo ""; //loop over all table rows and fetch them as an object while($result = $employees->fetch(PDO::FETCH_OBJ)) { //print out the details of each employee echo ""; //print out the Employee's No echo ""; //print out the Employee's First Name echo ""; //print out the Employee's Surname echo ""; //print out the Employee's Grade echo ""; echo ""; echo("\n"); } echo "
Emp_NoEmp_fnameEmp_snameGrade
" . $result->Emp_No . "" . $result->Emp_fname . "" . $result->Emp_sname . "" . $result->Grade . "
"; //link this PHP file to the PDO Insert script (insert_new_employee.php) echo "

"; echo "Insert a new employee record"; echo "

"; //close the database connection $conn = null; } //deal with any PDO connection execeptions. catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } ?>