<form action="posts-ayarlar.php" method="POST" id="demo-form2" data-parsley-validate class="form-horizontal form-label-left">
<table class="table table-striped table-bordered" >
<tr>
<thead>
<th scope="col">ID</th>
<th scope="col">BLOG TITLE</th>
<th scope="col">EDİT</th>
</thead>
</tr>
<?php
foreach($personellist as $person){
$xasr=$person->id;
?>
<tr>
<tbody>
<td><?= $person->id ?> </td>
<td><?= $person->title ?></td>
<td><button type="submit" name="post_ayar_guncelle_<?php echo $xasr ?>" class="btn btn-primary">Güncelle</button> </td>
<input type="hidden" name="giden" value="<?= $person->id ?>"/>
</tbody>
</tr>
<?php } ?>
</table>
</form>
在流程页面,您可以在左上角看到8,它是来自主编辑表页面的值。
<?php include 'connectionconfig.php';
$gelen=$_POST["giden"];
$sorgu=$db->prepare('SELECT * FROM posts where id:id');
$sorgu->execute(array('id'=>$gelen));
$personellist=$sorgu-> fetchAll(PDO::FETCH_OBJ);
?>
//example edit section
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Blog Title <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="title" id="first-name" required="required" class="form-control col-md-7 col-xs-12" value="<?php echo $personellist['title']; ?>">
</div>
</div>
这个想法是, 当我单击这些按钮之一时,我想使用该按钮 id 转到 process.php,然后我可以回调 id 所在的数据,因此网页将显示具有按钮 id 的编辑博客页面。但是当我单击其中的任何按钮时,由于 foreach 循环,值返回 8。
顺便一提; 我已经使用过ajax,但不知道为什么它不起作用。
FFIVE