Commit 38a91368 authored by suleman.hussain's avatar suleman.hussain

Replace drivers.php

parent a4e8c11c
......@@ -3,40 +3,21 @@
<body>
<?php
// Connects to database
$conn=mysqli_connect("ysjcs.net","suleman.hussain","WF8L8LE8","sulemanhussain");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql="SELECT * FROM Drivers";
$results = mysqli_query($conn,$sql);
// Table
if(isset($_POST['search_f_name'])) {
echo "<table>";
echo "<tr>";
echo "<th>First Name</th>";
echo "<th>Last Name</th>";
echo "<th>DoB</th>";
/*
echo "<th>Nationality</th>";
echo "</tr>";
while($row = mysqli_fetch_assoc($results)){
echo "<tr>";
echo "<td>" . $row["First_Name"]. "</td>";
echo "<td>" . $row["Last_Name"]. "</td>";
echo "<td>" . $row["DoB"]. "</td>";
echo "</tr>";
}
echo "</table>";
*/
if(isset($_POST['search'])) {
$search_term = $_POST['search_term'];
// Connect to the database
$conn = mysqli_connect("ysjcs.net","suleman.hussain","WF8L8LE8","sulemanhussain");
// Call the stored procedure
$results = mysqli_query($conn, "CALL search_proc('$search_term')");
$results = mysqli_query($conn, "CALL search_driver_name('$search_term')");
// Display the results
echo "</tr>";
......@@ -45,11 +26,41 @@ while($row = mysqli_fetch_assoc($results)){
echo "<td>" . $row["First_Name"]. "</td>";
echo "<td>" . $row["Last_Name"]. "</td>";
echo "<td>" . $row["DoB"]. "</td>";
echo "<td>" . $row["Nationality"]. "</td>";
echo "</tr>";
}
echo "</table>";
}
if(isset($_POST['search_Nationality'])) {
echo "<table>";
echo "<tr>";
echo "<th>First Name</th>";
echo "<th>Last Name</th>";
echo "<th>DoB</th>";
echo "<th>Nationality</th>";
echo "</tr>";
$search_term = $_POST['search_term'];
// Connect to the database
$conn = mysqli_connect("ysjcs.net","suleman.hussain","WF8L8LE8","sulemanhussain");
// Call the stored procedure
$results = mysqli_query($conn, "CALL search_nat('$search_term')");
// Display the results
echo "</tr>";
while($row = mysqli_fetch_assoc($results)){
echo "<tr>";
echo "<td>" . $row["First_Name"]. "</td>";
echo "<td>" . $row["Last_Name"]. "</td>";
echo "<td>" . $row["DoB"]. "</td>";
echo "<td>" . $row["Nationality"]. "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
......@@ -70,10 +81,17 @@ echo "</table>";
<form method="post" action="">
<input type="text" name="search_term" id="search-bar" placeholder="Search Driver First Name">
<button type="submit" name="search" id="search-btn">
<button type="submit" name="search_f_name" id="search-btn">
<i class="fa fa-search"></i>
</button>
</form>
<form method="post" action="">
<input type="text" name="search_term" id="search-bar" placeholder="Search Nationality">
<button type="submit" name="search_Nationality" id="search-btn">
<i class="fa fa-search"></i>
</button>
</form>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment