我想通过php更新文本,我可以查询我的sql中的实际文本存储,并显示在输入框中,当我尝试更新时,没有任何更改,我把这个变量放在echo中,看看它是否有效,我可以在确认页面上阅读新的文本,但数据库上仍然没有任何变化,我直接在mysql上尝试更新,它有效这是我的代码
enter code here
<?php
include "../storescripts/connect_to_mysql.php";
// Parse the form data and add inventory item to the system
if (isset($_POST['thisID'])) {
$id = $_POST['thisID'];
$name = 'names';
$textes = $_POST['textes'];
// See if that product name is an identical match to another product in the system
$sql = mysql_query("UPDATE library SET name='$name',textes='$textes'WHERE id='$id");
echo ''.$id.' New text is online, cliquer <a href="inventory_list.php">ici</a>.';
exit();
}
?>
and my form
<form action="text_edit.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
<table width="90%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%" align="right">Title</td>
<td width="80%"><label>
<input name="name" type="text" id="name" size="64" value="<?php echo $name; ?>" />
</label></td>
</tr>
</form>
</td>
</tr>
<?php echo ''.$targetID.' ';?>
<tr>
<td align="right">Text</td>
<td><label>
<textarea name="textes" id="textes" cols="64" rows="5"><?php echo $textes; ?> </textarea>
</label></td>
</tr>
<tr>
<td> </td>
<td ><label>
<input name="thisID" type="hidden" value="<?php echo $targetID; ?>" />
<input type="submit" name="button" id="btnsaveedit" value="Save Changes" />
</label>
$sql = mysql_query("UPDATE library SET name='$name',textes='$textes'WHERE id='$id");
指示
$sql=mysql_query("更新库SET name='$name',textes='$textes'WHERE id=$id");
首先,您必须确保$targetID变量有一个值,然后</form>
标记必须在所有表单字段的末尾关闭。
$sql = "UPDATE library SET name='".$name."',textes='".$textes."' WHERE id = '".$id."'";
mysql_query($sql);