I have a combo box "verb" that displays a field of database .. when the user selects "other" from the drop down ...a div named "choicetext" appears and user enters his choice of verb ....

The below code is of the action page ..in which i want to insert the "choicetext" value in that field of database... but should enter nothing if the user slects from the existing dropdown of "verb"

I succceded to enter the new one .. but whenever the user selects frm existing dropdown .. a blank entry happens in DB ...Plz help me ..thanx in advance

<?php
 $verb=$_REQUEST['verb'];
 $item=$_REQUEST['item'];
 $choice_verb=$_REQUEST['choicetext'];
 $verb_category="SRS";
 $added_by="";
 $added_on=date("Y/m/d");;
 $status=1;
 
if('$choicetext'!="" && '$verb'=="other") {

// Insert data into tb_verb_master 
$sql="INSERT INTO  tbl_verbs_master(verb_category,verb_description,added_by,added_on,status)VALUES('$verb_category', '$choice_verb','$added_by','$added_on','$status')";
$result2=mysql_query($sql) or die(mysql_error());

  }
  else {
          ?????
  }

try this

//if('$choicetext'!="" && '$verb'=="other"){
if($choicetext !="" && $verb=="other"){ //see the difference? variables are without the single quote

try this

//if('$choicetext'!="" && '$verb'=="other"){
if($choicetext !="" && $verb=="other"){ //see the difference? variables are without the single quote

Thnnk you so very much ... :).. that worked ...

can u help me one more thing ...when i enter through choicebox (i.e other option) the variable "verb_category" which is already defines as "SRS" is not being entered ... y so ?even the date is like 0000-00-00 :(

once check your database table column data type once for these two fields : verb_category,added_on.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.