I would like to edit the old values in a table
$row=mysql_fetch_row($res); //get two values in a row from mysql
$value
is obtain from $_GET['value']
and is used in the following form
<form action="renew.php?value='.$value.'" method="POST">
Enter your value: <br/>
<input type="text" name="firstvalue" size="30" value="'.$row[0].'"/><br/>
Enter another value:<br/>
<textarea name="secondvalue" col="10">'.$row[1].'</textarea><br/>
<input type="submit" value="Done!"/>
</form>
I'd like to post this form then renew the old values in mysql table with the new firstvalue and secondvalue. I'm stuck now.
In the renew.php I try this
$oldvalue=$_GET['value'];
print_r($oldvalue);
$newval1=$_POST['secondvalue'];
$newval2=$_POST['firstvalue']; // An unexpected syntax error for T_VARIABLE here
$query=sprintf("UPDATE tebo SET value1='%s',value2='%s' WHERE value1='%s' LIMIT 1",
$newval1,$newval2,$oldvalue);
mysql_query($query) or die("Unable to update the specified data. ".mysql_error());
$oldvalue=$_GET['value'];
$newval1=$_POST['secondvalue'];
$newval2=$_POST['firstvalue'];
$query="UPDATE tebo SET value1='".$newval1."',value2='".$newval2."' WHERE value='".$oldvalue."' ";
mysql_query($query) or die("Unable to update the specified data. ".mysql_error());
You forgot to put ; on bellow line
$newval1=$_POST['secondvalue'];
$newval2=$_POST['firstvalue'];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.