sql - Getting the value from drop down list using PHP -


i have form users enter values , update records.

the drop down menu looks this:

    <select name="dateid" required>         <option value="" disabled>please select...</option>         <option value="2">1920's</option>         <option value="3">1930's</option>         <option value="4">1940's</option>         <option value="5">1950's</option>         <option value="6">1960's</option>         <option value="7">1970's</option>         <option value="8">1980's</option>         <option value="9">1990's</option>     </select> 

then value of drop down chosen using this:

$decade = $_get['dateid']; 

this part causing me problems think.. sql statemen works when try in php myadmin doesn't work on website.

here sql statement:

   $sql = mysqli_query($con, "update details inner join date on date.dateid = details.dateid set details.year = '$year', details.description = '$description', details.dateid = '$decade' id='$recordid'") or die('query error. try again: '.mysqli_error()); 

this joining 2 tables, 1 has details in , has decade , date id according decade.

i trying assign value of drop down list dateid in both details , date table, meaning can assign decade ever value assigned.

why sql not working?

if replace sql works:

"update details set year = '$year', description = '$description' id='$recordid'" 

here recommendations:

  1. replace date `date`. date data type in mysql.
  2. relace where id='$recordid' <table alias>.id. id may present in both tables , using join.
  3. get values of variables using proper escaping sequence e.g. instead of "'$varname'" use "'".$varname."'" or "'{$varname}'"

hope resolving problem.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -