This code receives the staffID from a input text box and then displays details or purchases of that staffID. I want to be able to make a possible statement(IF statement most likely) that checks that the staffID exists and if it doesn't "invalid staff Id" is echo'd. Can anyone help please?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Prac 2 Task 3</title>
</head>
<body>
<?php
$conn = mysql_connect("localhost", "twa291", "twa291up");
mysql_select_db("factory291", $conn)
or die ('Database not found ' . mysql_error() ); ?>
<?php
$staffid= $_GET["staffID"];
?>
<?php
$sql = "SELECT orderID, orderDate, orderDate, shippingDate, staffName FROM purchase,
staff
WHERE staff.staffID='$staffid'";
$rs = mysql_query($sql, $conn)
or die ('Problem with query' . mysql_error());
?>
<table border="1" summary="Staff Orders">
<tr>
<th>Order ID</th>
<th>Order Date</th>
<th>Shipping Date</th>
<th>Staff Name</th>
</tr>
<?php
while ($row = mysql_fetch_array($rs)) { ?>
<tr>
<td><?php echo $row["orderID"]?></td>
<td><?php echo $row["orderDate"]?></td>
<td><?php echo $row["shippingDate"]?></td>
<td><?php echo $row["staffName"]?></td>
</tr>
<?php }
mysql_close($conn); ?>
</table>
</body>
</html>