1
我有一个标准的HTML表格,表格中的每一行都是使用循环从数据库表格生成的。更新表格行中的数据[PHP]
在每一行的末尾,我有一个更新按钮,我希望这可以更新表字段中的数据。
下图显示了这个概念。
表本身
<div class="container" id="users">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<form method="post" action="">
<table class="table table-bordered table-hover table-striped tablesorter">
<thead>
<tr>
<th width="10%" style="text-align:left">Forename</th>
<th width="15%" style="text-align:left">Surname</th>
<th width="35%" style="text-align:left">Email</th>
<th width="30%" style="text-align:left">Permissions</th>
<th width="5%" style="text-align:left">Update</th>
<th width="5%" style="text-align:left">Delete</th>
</tr>
</thead>
<tbody>
<tr>
<!--here showing results in the table -->
<?php
$adminquery = "SELECT * FROM admin ORDER by user_id DESC";
$IDlist = mysqli_query($dbconEDB, $adminquery);
while($rowlist=mysqli_fetch_array($IDlist))//while look to fetch the result and store in a array $row.
{
$user_id = $rowlist["user_id"];
$admin_email = $rowlist["admin_email"];
$forename = $rowlist["forename"];
$surname = $rowlist["surname"];
$JPortal = $rowlist["JPortal"];
$Tenders = $rowlist["Tenders"];
$News= $rowlist["News"];
$Events = $rowlist["Events"];
$Users= $rowlist["Users="] ;
?>
<td style="text-align:left">
<div class="form-group">
<input name="user_id" id="user_id" type="text" class="form-control" value="<?php echo $user_id;?>">
<input name="forename" id="forename" type="text" class="form-control" value="<?php echo $forename;?>">
<div class="hidden"> <?php echo $forename;?></div>
</div>
</td>
<td style="text-align:left">
<div class="form-group">
<input name="forename" id="surname" type="text" class="form-control" value="<?php echo $surname;?>">
<div class="hidden"> <?php echo $surname;?></div>
</div>
</td>
<td style="text-align:center">
<div class="form-group">
<input name="admin_email" id="admin_email" type="text" class="form-control" value="<?php echo $admin_email;?>">
<div class="hidden"> <?php echo $admin_email;?></div>
</div>
</td>
<td style="text-align:center">
<label>
<input name="JPortal" type="checkbox" id="JPortal" value="1" <?php if ($JPortal == 1) echo "checked='checked'" ;?>> Jobs
</label>
<label>
<input type="checkbox" name="Tenders" value="1" id="Tenders" <?php if ($Tenders == 1) echo "checked='checked'" ;?>> News
</label>
<label>
<input type="checkbox" name="News" value="1" id="News" <?php if ($News == 1) echo "checked='checked'" ;?>> Tenders
</label>
<label>
<input type="checkbox" name="Events" value="1" id="Events" <?php if ($Events == 1) echo "checked='checked'" ;?>> Events
</label>
<label>
<input type="checkbox" name="Users" value="1" id="Users" <?php if ($Users == 1) echo "checked='checked'" ;?>> Users
</label>
</td>
<td style="text-align:center">
<input class="btn btn-newable " type="submit" value="Update" name="EDBsubmit">
</td>
<td style="text-align:center">
<a href="users.php?user=<?php echo $user_id; ?>"><button class="btn btn-newable">update2</button></a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</form>
</div>
</div>
</div>
我想我只是有一个休息日,并可能在事实上缠表的每一行的形式。
请到目前为止添加您尝试的代码段。 Stackoverflow不仅仅是人们为你做所有工作的地方。 –
好吧:)现在就做。 –
为什么我的评论被删除? – Script47