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:
- replace date `date`. date data type in mysql.
- relace
where id='$recordid'
<table alias>.id
. id may present in both tables , using join. - get values of variables using proper escaping sequence e.g. instead of
"'$varname'"
use"'".$varname."'"
or"'{$varname}'"
hope resolving problem.
Comments
Post a Comment