I am trying to create a web page the shows competitors from past car rallys. This is the result so far when searching for "barry" as a firstname.
I would like to add a thumbnail image of the car. At the moment the image is stored in the database as blob. How do I code this to show the image.
Code so far. csvsearch.html
<html>
<body>
<form action="csvtable.php" method="post">
Search <input type="text" name="search"><br>
Column: <select name="column">
<option value="DriverFirstName">Driver First</option>
<option value="NavFirstName">Nav First</option>
<option value="Car">Car</option>
</select><br>
<input type ="submit">
</form>
</body>
</html>
csvtable.php
<?php
$search = $_POST['search'];
$column = $_POST['column'];
$servername = "localhost";
$username = "root";
$password = "";
$db = "csv_db";
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error){
die("Connection failed: ". $conn->connect_error);
}
$sql = "SELECT * FROM competitors WHERE $column like '%$search%'";
if($result = mysqli_query($conn, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table border='1' cellspacing='0' cellpadding='10'>";
echo "<tr>";
echo "<th>Driver</th>";
echo "<th>Co-Driver</th>";
echo "<th>Comp #</th>";
echo "<th>Category</th>";
echo "<th>Car</th>";
echo "<th>Event</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['DriverFirstName'] .' '. $row['DriverLastName'] . "</td>";
echo "<td>" . $row['NavFirstName'] . ' '. $row['NavLastName'] ."</td>";
echo "<td align='center'>" . $row['CompNumber'] . "</td>";
echo "<td>" . $row['Category'] . "</td>";
echo "<td>" . $row['CarYear'] .' ' . $row['Car'] .' '. $row['Model'] ."</td>";
echo "<td>" . $row['Event'] .' ' . $row['EventYear'] ."</td>";
echo "</tr>";
}
echo "</table>";
// Close result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
// Close connection
$conn->close();
// code from
?>
Any ideas please? .... even if I have to start all over again going down a different path.