如何在不刷新页面的情况下更新记录,我有一个系统,我想更新记录,在 0 和 1 之间更改其状态,以打开或关闭功能。这是我打开或关闭它的表格:
<table class="tablesorter" cellspacing="0">
<thead>
<tr>
<th></th>
<th>nane</th>
<th>time</th>
<th>out</th>
<th>enter</th>
<th>
<div align="center">admin</div>
</th>
<th></th>
</tr>
</thead>
<tbody>
<?php $qu_req=mysql_query( "select * from `exit_request` where `date`='$date_now' order by id desc "); while($row_req=mysql_fetch_row($qu_req)){ ?>
<tr>
<td>
<input type="checkbox">
</td>
<td><a href="show_exit_req.php?id=<?php print($row_req[0]); ?>" class="style9" onclick="NewWindow(this.href,'name','400','300','yes');return false"><?php print($row_req[1]); ?></a>
</td>
<td>
<?php print($row_req[2]); ?>
</td>
<td>
<?php print($row_req[6]); ?>
</td>
<td>
<?php print($row_req[7]); ?>
</td>
<td>
<div align="center">
<input name="<?php print(" chk_exit ".$row_req[0]); ?>" type="radio" value="0" <?php if($row_req[3]==0){print( 'checked');} ?>/>
<label>accept</label>
<input name="<?php print(" chk_exit ".$row_req[0]); ?>" type="radio" value="1" <?php if($row_req[3]==1){print( 'checked');} ?>/>
<label>not acept</label>
</div>
</td>
<td>
<input class="alt_btn" name="send" type="submit" value="رد الادارة" />
</td>
</tr>
<? } ?>
</tbody>
</table>
更新代码
if(isset($_POST['send'])){
$qu=mysql_query("select * from `exit_request` ");
while($row=mysql_fetch_row($qu)){
$id=$row[0];
$chk_str="chk_exit".$id;
$chk_str=$$chk_str;
//if($chk_str==1)
mysql_query("update `exit_request` set `accept`='$chk_str' where id=$id");
print('<meta http-equiv="refresh" content="0;URL=index.php" />');
}
}