I know I have to use a UPDATE query. I will post some code here that I have been working with but isn't working for me so maybe someone can have a look at the code below and tell me why it isn't working for me. Please ignore the variables I just wanted to focus on the code that is below.
Code: Select all
$insert = "INSERT INTO `clearingsales` (`selectDay`, `selectDate`, `selectMonth`, `selectYear`, `propertyname`, `time`, `ampm`, `accountname`, `comments`, `select1`, `txt1`, `select2`, `txt2`, `select3`, `txt3`, `select4`, `txt4`, `select5`, `txt5`, `select6`, `txt6`, `select7`, `txt7`, `select8`, `txt8`, `select9`, `txt9`, `select10`, `txt10`, `select11`, `txt11`) VALUES ('$selectDay', '$selectDate', '$selectMonth', '$selectYear', '$propertyname', '$time', '$ampm', '$accountname', '$comments', '$select1', '$txt1', '$select2', '$txt2', '$select3', '$txt3', '$select4', '$txt4', '$select5', '$txt5', '$select6', '$txt6', '$select7', '$txt7', '$select8', '$txt8', '$select9', '$txt9', '$select10', '$txt10', '$select11', '$txt11')";
if (mysql_query ($insert)) {
if (($select1 == 'other') && (!empty($other1))) {
$update = "UPDATE clearingsales SET select1 = '$other1' WHERE propertyname = '$propertyname'";
if (mysql_query ($update)) {
header ("Location: clearing_sale_added.php");
} else {
print "<p>Could not update the entry because: <b>" . mysql_error() . "</b>. The query was $update.</p>";
}
}