If you want more of my pastes visit: https://randompaste.000webhostapp.com/index.html -------------------------------------------------------------------------------------- Task3
setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); $sql = "SELECT * FROM modules"; //output in a table form echo "

SQL Query using PDO showing results in Table form

"; echo " "; echo ""; foreach ($conn->query($sql) as $row) { echo ""; } //end for each //defining variables to enter into database $sqlValueCode=""; $sqlValueName=""; $sqlValueLecturer=""; ?>
CodeNameLecturer
" . $row["code"] . " " . $row["name"] . " " . $row["lecturer"] . "


Add Form
Code

Module Name

Lecturer

". $modCode . "
" . $modName . "
". $lectName ; //define sql insert command $sqlAdd= "INSERT INTO modules (code, name, lecturer) values ("."'$sqlValueCode',"." '$sqlValueName',"." '$sqlValueLecturer')"; //only inserting data if variables have been set if ($sqlValueCode != NULL or $sqlValueName != NULL or $sqlValueLecturer != NULL) { //executing sql insert command $conn->exec($sqlAdd); echo "entry added successfully"; } else { echo "could not add the entry"; } ?>

Update Form
Code

Module Name

Lecturer