cturner Posted January 25, 2007 Share Posted January 25, 2007 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 More sharing options...
suzzane2020 Posted January 25, 2007 Share Posted January 25, 2007 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 sou cud check this before insertinwhen u get the values thru postcheck: if($select1=='other'){ $select1=$other1;}else{ $select1=$select1;}and then insert the $select1 as u usually do.. Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168750 Share on other sites More sharing options...
cturner Posted January 25, 2007 Author Share Posted January 25, 2007 I have tried your code suzzane2020 it still isn't replacing the data. Could this problem have something to do with the text box ($other) be hidden before the combo box selection ($select1)? Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168769 Share on other sites More sharing options...
suzzane2020 Posted January 25, 2007 Share Posted January 25, 2007 do u generate the textbox dynamically..like when the user selects other in te select option te textbox appears or isit included in your html Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168772 Share on other sites More sharing options...
trq Posted January 25, 2007 Share Posted January 25, 2007 You'll need to be allot clearer in the description of your problem. I have no idea what your talking about. Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168773 Share on other sites More sharing options...
suzzane2020 Posted January 25, 2007 Share Posted January 25, 2007 or better still hw bout checkin i te textbox has a value and if it does insert that n i not the select valueif($other!=""){ $value=$other;}else{ $value=$select;} Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168775 Share on other sites More sharing options...
cturner Posted January 25, 2007 Author Share Posted January 25, 2007 I have now solved the problem. Thanks to suzzane2020. :) Link to comment https://forums.phpfreaks.com/topic/35625-solved-updating-doesnt-replace-data/#findComment-168777 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.