如果我插入了行并且我想更新此行中插入的这一行的一个列值而不更新此前一个过程中插入的旧行的一列值 您可以看到我的代码和更清楚地了解:更新立即插入行而不更新旧版
<?php
session_start(); ?>
<form action="" method="post" name="data_table">
<tbody >
<?php
require_once("dbconfig.php");
error_reporting(0);
$id=$_POST['id'];
$class=$_POST['class'];
$d = new DateTime('now', new DateTimeZone('Asia/Baghdad'));
$date=$d->format('Y-m-d H:i:s');
$q="select * from students WHERE class='$class'";
$qq=mysql_query($q)
or die(mysql_error());
echo "<table border='2'>
<tr>
<th>الأسم</th>
<th>الحضور</th>
</tr><tr>";
while($row=mysql_fetch_array($qq)){
?>
<input type="hidden" name="class" value="<?php echo $row['class']; ?>" >
<td><input type="checkbox" value="<?php echo $row['id']; ?>" name="id[]" ></td>
<td><b><?php echo $row['username']; ?></td>
<tr>
<?php } ?>
</table>
<?php if (isset($_POST['submit']))
{if(empty($id) || $id==0)
{ echo " please check ";
}
else
{
$impid=implode(", ",$id);
$qdel=mysql_query("INSERT INTO attendees SELECT * FROM `students` WHERE class='$class'");
$qdel=mysql_query("UPDATE attendees set datetime='$date'");
if (isset($qdel)){
echo "<h2> done </h2>";}
}
} ?>
</tbody>
</form>
问题是现在插入更新查询更新所有行日期时间列的值和前现在,所以我的问题是,如何才能让每个插入过程更新查询工作与前一个分开 任何人都可以帮忙吗?谢谢
我从你的描述中无法理解任何东西。 –
请停止使用PHP的陈旧,不安全和不推荐使用mysql_ API – Strawberry
你没有在'UPDATE'中使用'WHERE' –