我能够在表格中显示数据行。我想在每个表的末尾放一个按钮,以便我能够删除/编辑该特定行。所以这是
$found_row = 0;
$result = mysqli_query($conn,"SELECT * from TICKET INNER JOIN CUSTOMER ON TICKET.CUSTOMER_ID=CUSTOMER.CUSTOMER_ID");
echo "<table>"; // start a table tag in the HTML
echo "<tr>
<th>Ticket ID</th>
<th>Customer ID</th>
<th>Name</th>
<th>Address</th>
<th>Phone</th>
<th>Email</th>
<th>Pickup Date</th>
<th>Pickup Time</th>
<th>Delivery Date</th>
<th>Delivery Time</th>
<th>Payment Mode</th>
<th>Payment Status</th>
<th>Ticket Status</th>
<th>EDIT STATUS</th>
</tr>";
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
$found_row = true;
$wow = $row['TICKET_ID'];
echo " <tr>
<td>".$row['TICKET_ID']."</td>
<td>".$row['CUSTOMER_ID']."</td>
<td>".$row['CUSTOMER_NAME']."</td>
<td>".$row['CUSTOMER_ADDRESS']."</td>
<td>".$row['CUSTOMER_PHONE']."</td>
<td>".$row['CUSTOMER_EMAIL']."</td>
<td>".$row['TICKET_PICKUP']."</td>
<td>".$row['TICKET_PTIME']."</td>
<td>".$row['TICKET_DELIVERY']."</td>
<td>".$row['TICKET_DTIME']."</td>
<td>".$row['TICKET_PAYMENT']."</td>
<td>".$row['PAYMENT_STATUS']."</td>
<td>".$row['TICKET_STATUS']."</td>
<td>".("<a href='cancelticket1.php?id=$wow'>Delete</a>")."</td></tr>";
}
if ($found_row == false) {
echo "No Ticket Submitted";
}
echo "</table>";
所以现在我能够为每行重定向具有ticket_id返回值的页面。例如,url为/cancelticket1.php?id=1001。并在页面cancelticket1.php中,这是代码:
$cancelticket=$_GET['$wow'];
$sql = "DELETE FROM TICKET WHERE TICKET_ID=$cancelticket";
if ($conn->query($sql) === TRUE) {
echo "Ticket Has Been Deleted";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
从这里我很难理解如何检索该ticket_id,并且我不断收到错误消息但是我试过了。请帮我。
答案 0 :(得分:-1)
更改密码:
$cancelticket=$_GET['$wow'];
到
$cancelticket=$_GET['id'];