Hello Forum members!
I have this php code how can I modify it to display the result which I am expecting?
<?php include 'includes/dbConnect.inc.php';
$conn = dbConnect('query');
if(array_key_exists('Submit', $_POST)){
$surname = htmlspecialchars($_POST['surname']);
$driverRegNo = htmlspecialchars($_POST['driverRegNo']);
if(isset($surname)){
$searchitem = htmlspecialchars($_POST['searchitem']);
$query = "SELECT *
FROM drivers
WHERE surname LIKE '%$searchitem%'
ORDER BY surname";
$numresults=mysql_query($query) or die(mysql_error());
$numrows=mysql_num_rows($numresults);
}
elseif(isset($driverRegNo)){
$searchitem = htmlspecialchars($_POST['searchitem']);
$query = "SELECT *
FROM drivers
WHERE driverRegNo LIKE '%$searchitem%'
ORDER BY surname";
$numresults=mysql_query($query) or die(mysql_error());
$numrows=mysql_num_rows($numresults);
}//ongezwad*/
elseif($numrows == 0){
echo 'Your search for <b>' .$searchitem. '</b> could not be found';
}else{?>
<!--/*while($row = mysql_fetch_assoc($numresults)){
echo 'You searched for '. $row['surname'];
}*/-->
<table id="main">
<tr>
<th>DRIVER LICENCE No.</th>
<th>SURNAME</th>
<!--<th>OTHERNAMES</th>-->
<th>GENDER</th>
<!--<th>ADDRESS</th>-->
<th> TELEPHONE No.</th>
<!--<th>PLACE OF BIRTH</th>
<th>NATIONALITY</th>-->
<!-- <th>SCHOOL ATTENDED</th>
<th>LICENCE ISSUE DATE</th>
<th>LICENCE CLASS</th>
<th>ISSUING AUTHORITY</th>
<th>LICENCE EXPIRY DATE</th>-->
<!--<th scope="col">driver Reg NO</th>
<th scope="col">surname</th>
<th scope="col">othernames</th>
<th scope="col">gender</th>
<th> </th>
<th> </th>-->
</tr>
<?php
while($row = mysql_fetch_assoc($numresults)) {
?>
<tr>
<td id="midcontent"><?php echo $row['driverRegNo']; ?></td>
<td id="midcontent"><?php echo $row['surname']; ?></td>
<!-- <td id="midcontent"><php echo $row['othernames']; ?></td>-->
<td id="midcontent"><?php echo $row['gender']; ?></td>
<!--<td id="midcontent"><php echo $row['address']; ?></td>-->
<td id="midcontent"><?php echo $row['telephoneNo']; ?></td>
<!--<td id="midcontent"><php echo $row['placeOfBirth']; ?></td>
<td id="midcontent"><php echo $row['nationality']; ?></td>-->
<!-- <td id="midcontent"><php echo $row['schoolName']; ?></td>
<td id="midcontent"><php echo $row['issueDate']; ?></td>
<td id="midcontent"><php echo $row['licenceClass']; ?></td>
<td id="midcontent"><php echo $row['issuingAuthority']; ?></td>
<td id="midcontent"><php echo $row['expiryDate']; ?></td>-->
<td id="midcontent"><a href="Update_Drivers.php?driverID=<?php echo $row['driverID']; ?>">Edit</a></td>
<td><a href="delete_driver.php?driverID=<?php echo $row['driverID']; ?>">Remove</a></td>
</tr>
<?php } ?>
</table>
<?php }
}
?>
and here is its html form
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="" method="post" name="searchform" id="">
<div> <label for="searchdata">Select Criteria for Search</label>
<select name="searchdata" id="searchdata">
<option value="surname">Driver's Surname</option>
<option value="driverRegNo">Driver's Licence No.</option>
</select>
</div>
<div>
<label for="searchdata">Type your search criteria</label><input type="text" name="searchitem" id="searchitem" />
</div>
<div>
<input name="Submit" type="submit" value="Search" />
</div>
</form>
</body>
</html>
thank you, inadvance