Jump to content

[SOLVED] Updating doesn't replace data


cturner

Recommended Posts

The code below is suppose to replace $select1 (a combo box) with $other1 (a text box) but it doesn't. Can someone please have a look at my code and tell me how I could do what it is suppose to do? Thanks in advance.

[code=php:0]
$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)) || ($select1 == 'other') && (!empty($other1))) {
//if (($select1 == 'other') && (!empty($other1))) {
$update = "UPDATE clearingsales SET select1 = '$other1' WHERE propertyname = '$propertyname'";
header ("Location: clearing_sale_added.php");
//}
//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>";
//}
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert.</p>";
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/
Share on other sites

i guess wat ur trin to do is check if the select box has 'other' and if so enter the 'other' value in the database..k if this is so


u cud check this before insertin

when u get the values thru post

check:  if($select1=='other')
{
  $select1=$other1;
}

else
{
  $select1=$select1;
}

and then insert the $select1 as u usually do..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.