Hi i've got a table thats populated by a mysql database and what i want to happen is if you click save and the table row is empty then it inserts the new details, but if there is something in the table row then when you click save it updates the information thats there. The problem i'm having is it either replaces the whole lot or if always adds a new one and not over rights the old, heres the code that i'm using if thats any help.
<?
$db = mysql_connect ("localhost", "root", "orange");
mysql_select_db ("camco", $db);
$query = "SELECT lambitem,custno FROM workdetail";
$res = mysql_query ($query, $db);
$row = mysql_fetch_row ($res);
if ($idno == '$row[7]')
{
$sql = "UPDATE workdetail SET lambitem='$lams',staff='$staff',hours='$hours',cost='$cost',datecomp='$donedate' WHERE idno=$idno";
$res = mysql_query ($sql, $db);
}
else
{
$query = "INSERT INTO workdetail (servicetype,lambitem,staff,hours,cost,datecomp,custno,aircraftreg) VALUES ('$Servicetype','$lams','$staff','$hours','$cost','$donedate','$jobid','$aircraftreg')";
$res = mysql_query ($query, $db);
}
mysql_close ($db);
header ("Location: work_carried_out.php?jobno=$jobid");
?>
thanks.