在编写代码以将我的mysql的结果回显到我的数据库表之后,现在我正在尝试将所选行放在我的更新页面上,就像从表中显示一些信息一样,并且能够更新该表同时
我对我在其他地方实际阅读的所有在线帮助感到困惑,但我相信我写了正确的代码,但可能只是遗漏了一些我认为可以帮助我的东西。 这里是index.php ,显示我的数据库中的表
<?php
//include auth.php file on all secure pages
require("../db.php");
session_start();
if(!isset($_SESSION["username"])){
header("Location: login");
exit(); }
?>
<?php require_once('header.php')?>
<div class="container content">
<table id="myTable" class="table table-striped" >
<thead>
<tr>
<th>ConsignmentNo</th>
<th>Origin</th>
<th>Destination</th>
<th>PickupDate</th>
<th>Status</th>
<th >Actions</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($con,"SELECT * FROM consignment");
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['consignmentno'] . "</td>";
echo "<td>" . $row['shipmentorigin'] . "</td>";
echo "<td>" . $row['shipmentdestination'] . "</td>";
echo "<td>" . $row['shipmentpickupdate'] . "</td>";
echo "<td>" . $row['shipmentstatus'] . "</td>";
echo "<td><a name='consignmentno' href='update.php?id=".$row['consignmentno']."'>Edit</a></td>";
echo "</tr>";
}
mysqli_close($con);
?>
</tbody>
</table>
</div>
</div>
<?php require_once('footer.php')?>
这是 处理我的请求的 update.php 页面
<?php
require("../db.php");
$track = $_GET['consignmentno'];
$sql = "SELECT * FROM `consignment` WHERE consignmentno='$track'";
$result = $con->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$consignmentno = $row['consignmentno'];
$shippername = $row['shippername'];
$shipperphone = $row['shipperphone'];
$shipperaddress = $row['shipperaddress'];
$shipperemail = $row['shipperemail'];
$receivername = $row['receivername'];
$receiverphone = $row['receiverphone'];
$receiveraddress = $row['receiveraddress'];
$receiveremail = $row['receiveremail'];
$shipmenttype = $row['shipmenttype'];
$shipmentweight = $row['shipmentweight'];
$shipmentcourier = $row['shipmentcourier'];
$shipmentpackage = $row['shipmentpackage'];
$shipmentmode = $row['shipmentmode'];
$shipmentproduct = $row['shipmentproduct'];
$shipmentquantity = $row['shipmentquantity'];
$shipmentfrieght = $row['shipmentfrieght'];
$shipmentcarrier = $row['shipmentcarrier'];
$departeddate = $row['departeddate'];
$shipmentorigin = $row['shipmentorigin'];
$shipmentdestination = $row['shipmentdestination'];
$shipmentpickupdate = $row['shipmentpickupdate'];
$shipmentstatus = $row['shipmentstatus'];
$shipmentexpected = $row['shipmentexpected'];
$comment = $row['comment'];
}
} else {
echo "NO DETAILS FOR USER";
}
$con->close();
?>
<?php require_once('header.php')?>
<div class="container content">
<script type="text/javascript">
$(document).ready(function(){
txt=$("#UpdateStatus").val();
if(txt=='3')
{
$("#receive").slideDown("slow");
$("#UpdateReceivedBy").removeAttr("disabled");
}
else
{
$("#receive").slideUp("slow");
$('#UpdateReceivedBy').attr('disabled', 'true');
}
$("#UpdateStatus").change(function(){
txt=$("#UpdateStatus").val();
if(txt=='3')
{
$("#receive").slideDown("slow");
$("#UpdateReceivedBy").removeAttr("disabled");
}
else
{
$("#receive").slideUp("slow");
$('#UpdateReceivedBy').attr('disabled', 'true');
}
});
});
</script>
<h2 class="col-md-offset-5">Update Shipment</h2>
<div class="row">
<div class="table-responsive col-md-8 col-md-offset-2">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th><h4><?php echo $consignmentno ; ?></h4>
</th>
<th>
<h2>On Hold</h2>
</th>
</tr>
</thead>
但它没有回应$consignmentno
因为它可以做到这一点然后其他所有事情变得更容易
所以请帮我检查一下我弄错了。感谢
答案 0 :(得分:0)
您必须将update.php?id=
替换为update.php?consignmentno=
,line 35
它将解决您的问题
或者在 index.php
中使用此代码<?php
//include auth.php file on all secure pages
require("../db.php");
session_start();
if(!isset($_SESSION["username"])){
header("Location: login");
exit(); }
?>
<?php require_once('header.php')?>
<div class="container content">
<table id="myTable" class="table table-striped" >
<thead>
<tr>
<th>ConsignmentNo</th>
<th>Origin</th>
<th>Destination</th>
<th>PickupDate</th>
<th>Status</th>
<th >Actions</th>
</tr>
</thead>
<tbody>
<?php
$result = mysqli_query($con,"SELECT * FROM consignment");
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['consignmentno'] . "</td>";
echo "<td>" . $row['shipmentorigin'] . "</td>";
echo "<td>" . $row['shipmentdestination'] . "</td>";
echo "<td>" . $row['shipmentpickupdate'] . "</td>";
echo "<td>" . $row['shipmentstatus'] . "</td>";
echo "<td><a name='consignmentno' href='update.php?consignmentno=".$row['consignmentno']."'>Edit</a></td>";
echo "</tr>";
}
mysqli_close($con);
?>
</tbody>
</table>
</div>
</div>
<?php require_once('footer.php')?>