Hello all. I am trying to add a search field at the top of this that will allow me to search the MySQL database information and return the results in the same table view with the edit and delete options at the end of the table still. I want to be able to search by name and or id number. I cannot figure out how to do this and make it work properly. Hopefully someone in here can help me out. Thank you everyone in advance !
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>View RC Data</title>
<style type="text/css">
table { border-collapse:collapse; }
table td, table th { border:1px solid black;padding:5px; }
tr:nth-child(even) {background: #ffffff}
tr:nth-child(odd) {background: #ff0000}
</style>
</head>
<body>
<img src="logo.png" alt="logo">
<?php
/*
VIEW.PHP
Displays all data from 'rcrentals' table
*/
// connect to the database
include('connect-dbrc.php');
// get results from database
$result = mysql_query("SELECT * FROM rcrentals")
or die(mysql_error());
// display data in table
// echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>";
echo "<table border='1' cellpadding='5'>";
echo "<tr> <th>ID</th> <th>First Name</th> <th>Last Name</th> <th>Address</th> <th>City</th> <th>State</th> <th>Zip</th> <th>Phone</th> <th>DL</th> <th>Email</th> <th>Car and Controller</th> <th></th> <th></th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td>' . $row['address'] . '</td>';
echo '<td>' . $row['city'] . '</td>';
echo '<td>' . $row['st'] . '</td>';
echo '<td>' . $row['zip'] . '</td>';
echo '<td>' . $row['phone'] . '</td>';
echo '<td>' . $row['dl'] . '</td>';
echo '<td>' . $row['email'] . '</td>';
echo '<td>' . $row['carcont'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
// echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '" onclick="return confirm(\'Confirm?\')">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p><a href="../../rc/new.php">Manual Add Entry</a> :: <a href="#">Return to Main Admin Screen</a></p>
</body>
</html>