我需要使用提交的数据编辑我的数据库表。在php页面编辑sql数据
这是形式:
mysql_query("set names 'utf8'");
$query = "SELECT * FROM sec1octa";
$result = mysql_query($query);
?>
<div align="center">
<form method="get" action="edit_data.php">
<table width="104" border="1" class="center1">
<tr>
<th width="94">first</th>
<th width="94">second</th>
<th width="94">status</th>
</tr>
<tr>
<?php
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_array($result)) {
?>
<tr>
<td><input type="text" name="id" value="<?php echo $row ['stu_no']; ?> " size=10></td>
<td><input type="text" name="name" value="<?php echo $row ['stu_name']; ?> " size=10></td>
<td><?php
echo '<select name="status">'; {
echo '<option value="open">'.$row['stu_status'].'</option>';
echo '<option value="close">'.prevent.'</option>';
}
echo '</select>';
?></td>
</tr>
<?php
}
}
?>
</tr>
</table>
<input type="submit" name="submit" value="done" />
</form>
的问题是在edit_data.php页。 我不能UPDATE
。
我使用此代码,但它不工作。
require_once('../Connections/config.php');
$id= $_GET['id'];
$status= $_GET['status'];
$query= mysql_query("UPDATE `goh`.`sec1octa` SET `stu_status` = '$status'
WHERE stu_no='".$id."'") or die (mysql_error());
if($query){echo $status ."done ";}
你有一个错字:$ qeury而不是$查询。并分享你的错误。 – contremaitre
没有错误出现,它只是在我的数据库的2列,最后一列(编号42)和列编号(40)更新,当我尝试更新到另一列也更新到第42号 –
@ mickmackusa,我该如何清洁它? ,我怎样才能使用edit_data.php中的名字?或者它没有用? –