Hey i have this code below - the delete part works but the update doesn't there are no error codes it says it has been amended but it hasn't... any help would be great...
<?php
include "connection.php";
//gather data from form
$id=$_GET['id'];
$day=$_GET['Day'];
$type=$_GET['Type'];
$location=$_GET['Location'];
$time=$_GET['Time'];
$compulsory=$_GET['Compulsory'];
// Was the Amend presed
if (isset($_GET['Amend']))
{
$query = "UPDATE trainingw1 SET".
"Day = '$day', " .
"Type = '$type', " .
"Location = '$location', " .
"Time = '$time', " .
"Compulsory = '$compulsory', " .
"WHERE id = $id";
// execute query
$result = mysql_query($query) ;
echo "id ".$id." was amended OK";
}//end if
// Or was Delete pressed
else if (isset($_GET['Delete']))
{
$query1 = "DELETE FROM trainingw1 WHERE id = '$id'";
if (!($result = @ mysql_query ($query1, $connection))) die("No records deleted");
//Check the number of affected rows
if(mysql_affected_rows()==1)
{
//Deletion ran OK
echo "The entry with the name = $name was deleted";
}
else
{
//Failed to delete
echo "Could not delete entry with id = $id ";
}
}
echo $connection;
?>
<?php
include "connection.php";
//gather data from form
$id=$_GET['id'];
$day=$_GET['Day'];
$type=$_GET['Type'];
$location=$_GET['Location'];
$time=$_GET['Time'];
$compulsory=$_GET['Compulsory'];
// Was the Amend presed
if (isset($_GET['Amend']))
{
$query = "UPDATE trainingw1 SET".
"Day = '$day', " .
"Type = '$type', " .
"Location = '$location', " .
"Time = '$time', " .
"Compulsory = '$compulsory', " .
"WHERE id = $id";
// execute query
$result = mysql_query($query) ;
echo "id ".$id." was amended OK";
}//end if
// Or was Delete pressed
else if (isset($_GET['Delete']))
{
$query1 = "DELETE FROM trainingw1 WHERE id = '$id'";
if (!($result = @ mysql_query ($query1, $connection))) die("No records deleted");
//Check the number of affected rows
if(mysql_affected_rows()==1)
{
//Deletion ran OK
echo "The entry with the name = $name was deleted";
}
else
{
//Failed to delete
echo "Could not delete entry with id = $id ";
}
}
echo $connection;
?>