<?php
require_once '../mainfunctions.php';
printHead("3","3.1-3.3: Employee Table Display", "Connect to a database from a PHP Script <br> Send Queries to a database <br> Parse query results from a database and display on a webpage")
?>
<div id="chapterMain">
<!--PRINT CONFIRMATION OF DELETION or UPDATE--->
<?php
if(isset($_GET['actionheadervardeletefrom3-6'])){
echo "<p>Employee id# " . $_GET['idheadervardeletefrom3-6'] . " " . $_GET['actionheadervardeletefrom3-6'] ."....</p>";
}
if(isset($_GET['actionheadervarupdatefrom3-6'])){
echo "<p>Employee id# " . $_GET['idheadervarupdatefrom3-6'] . " " . $_GET['actionheadervarupdatefrom3-6'] ."....</p>";
}
?>
<!--PRINT CONFIRMATION OF ADD--->
<?php
if(isset($_GET['actionheadervaraddfrom3-4'])){
echo "<p>Employee id#" . $_GET['idheadervaraddfrom3-4'] . " " . $_GET['actionheadervaraddfrom3-4'] ."....</p>";
}
?>
<!---PRINT TABLE--->
<table>
<tr><th>ID</th><th>LastName</th><th>FirstName</th><th>Title</th><th>Email</th></tr>
<?php
$conn= createConn();
$query = "Select EmployeeId, LastName, FirstName, Title, Email from Employee";
$result = mysqli_query($conn,$query);
if (!$result){die(mysqli_error($conn));
}
if (mysqli_num_rows($result)>0){
while ($row=mysqli_fetch_assoc($result)){
?>
<tr>
<td> <?php echo $row['EmployeeId']; ?> </td>
<td> <?php echo $row['LastName']; ?> </td>
<td> <?php echo $row['FirstName']; ?> </td>
<td> <?php echo $row['Title']; ?> </td>
<td> <?php echo $row['Email']; ?> </td>
<td><a href="3.6-u.php?idlinkvarfrom3-3=<?php echo $row['EmployeeId']?>">Update1</a></td>
<td><a href="3.6-d.php?idlinkvarfrom3-3=<?php echo $row['EmployeeId']?>">Delete2</a></td>
</tr>
<?php
}
}
?>
</table>
</div>
<?php
printFootWithCodeExample('3.3code.php');
?>