ok so here is my list page now...
<html>
<head>
<title>Welcom to Carsales Warehouse</title>
</head>
<body bgcolor="black" style="color:white;">
<h2 align="center">List</h2>
<? $car_id= $_REQUEST['car_id']; ?>
<form Method="POST" ACTION="edit.php?car_id=$car_id">
<?php
include ('connect.php');//Includes database connection details
error_reporting(0);
session_start();
$_SESSION['username'] = "$username";
echo "<table border='1' align='center'>
<tr bgcolor='#cccccc'>
<td>Manufacturer</td>
<td>Make</td>
<td>Year</td>
<td>Price</td>
<td colspan='2'>Action</td>
</tr>";
$SQL = "Select * FROM cars";
$result = mysql_query($SQL);
while($row = mysql_fetch_array($result)){
$car_id=$row['car_id'];
echo "<tr><td>";
echo $row['manufacturer'];
echo "</td><td>";
echo $row['make'];
echo "</td><td>";
echo $row['year'];
echo "</td><td>";
echo $row['price'];
echo "</td><td>";
echo "<a href=edit.php?car_id=$car_id&update=yes>Edit</a>";
echo "</td><td>";
echo "<a href=delete.php?car_id=$car_id&delete=yes>Delete</a>";
echo "</tr>";
}
echo "</table>"; //end the table outside the loop
?>
</form>
</body>
</html>
and then my delete page
<html>
<head>
<title>Welcom to Carsales Warehouse</title>
</head>
<body bgcolor="black" style="color:white;">
<h2 align="center">Delete Vehicle</h2>
<p align="center">Are you sure you want to delete this vehicle?</p>
<?
// replace with the real car id value
$id = 'car_id_value';
?>
<form Method="POST" ACTION="delete.php">
<div align="center">
<input type="hidden" value="<? echo $id; ?>" name="car_id">
<input type="submit" value="Yes" name="delete">
<input type="submit" value="No" name="no" onClick="parent.location='list.php'">
</div>
</form>
<?php
include ('connect.php');//Includes database connection details
error_reporting(0);
$_SESSION['username'] = "$username";
$delete = $_POST['delete'];
$car_id= $_POST['car_id'];
$query = "SELECT manufacturer, make, year, price FROM cars WHERE car_id = '$car_id'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$manufacturer = $row['manufacturer'];
$make = $row['make'];
$year = $row['year'];
$price = $row['price'];
}
if (isset($_POST['delete']) == "Yes") {
//$car_id = $_POST["car_id"];
if(!empty($car_id)){
$sql = "DELETE FROM cars WHERE car_id = '$car_id'";
$result = mysql_query($sql) or die(mysql_error());
if($result){
echo "<p align = 'center'>The vehicle $manufacturer, $make, $year, with a price of R$price has been deleted!</p>";
} else {
echo '<p align="center">Your car id variable posted: '.$car_id.', but was not deleted.</p>';
}
} else {
echo '<p align="center">Your car id variable was not posted.</p>';
}
}
?>
</body>
</html>
At the moment if I run it like this, it prints "The vehicle , , , with a price of R has been deleted!" but does not actually delete the record. Also why does it not print the variables, like manufacturer, make, year and price?