Using the following code I can retrieve information from a mysql table and have the results displayed on the same page.
Is it possible to add a delete option next to each of the returned results to allow user to delete unwanted records
<h3>Please select your vehicle type</h3>
<form action = "<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Please select your vehicle type:
<select name="vehicle">
<option value="car">Car</option>
<option value="van">Van</option>
<option value="truck">Truck</option>
<option value="bus">Bus</option>
</select>
<input type="submit" value ="Search for tyres"/>
</form>
<?php
$vehicle = $_POST['vehicle'] ;
if ( $vehicle == '' )
{
// print "
no vehicle selected ..." ;
}
else
{
$host = "localhost";
$user = "root";
$password = "**";
$database = "**";
$table = "tyre";
$connection = mysql_connect($host, $user, $password)
or die ("Couldn't connect to server");
$db = mysql_select_db($database, $connection)
or die ("Couldn't connect to database");
$result = mysql_query("SELECT * FROM $table WHERE vehicle = '" . $vehicle . "'")
or die(mysql_error());
print "
Available tyres for: $vehicle
" ;
echo "<table border='1'>";
echo "<tr> <th>Vehicle</th> <th>Size</th> <th>Brand</th> <th>Price</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['Vehicle'];
echo "<td>";
echo $row['Size'];
echo "<td>";
echo $row['Brand'];
echo "</td><td>";
echo $row['Price'];
echo "</td></tr>";
}
echo "</table>";
}