<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="edit" class="btn btn-primary" value="edit"/>
<input type="submit" name="delete" class="btn btn-danger" value="Delete"/>
</div>
</form>
然后
if($_POST['action']=='edit'){
echo $rcode1=$_REQUEST['pass'];
$sqlup="select * from transport_details where rcode='$rcode1'";
没有名为action
的输入。无法访问您当前的代码。
$_POST
assoc 通过属性name
获取其密钥。
<input type="text" name="authorName" />
<?php
echo $_POST['authorName'];
?>
你的代码应该像(在PHP文件中(
if (isset($_POST['edit'])) { ... }
或(在 HTML 文件中(
<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="action" class="btn btn-primary" value="edit"/>
<input type="submit" name="action" class="btn btn-danger" value="Delete"/>
</div>
</form>
你可以在你的php中做到这一点...
if (isset($_POST['edit'])) {
echo $rcode1=$_POST['pass'];
$sqlup="select * from transport_details where rcode='".$rcode1."'";
}
假设你的HTML是这样的...
<form action="" method="post">
<div class="col-md-2 ">
<input type="type" value="<?php echo $row['rcode'];?>" name="pass" id="pass"/>
<input type="submit" name="action" class="btn btn-primary" value="edit"/>
<input type="submit" name="action" class="btn btn-danger" value="Delete"/>
</div>
</form>
您应该能够获得值