嘗試通過從數據庫中選擇預訂引用來創建列表,將它們排序到數組中,然後將每個數組值傳遞到列表中的每個項目。例如第一個項目的第一個預訂參考,第二個項目的第二個參考等... 這裏是代碼。如何使用數據庫和數組中的fetch_assoc創建無序列表
<html>
<head>
<title>Manage booking</title>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<body>
<h3>Oadby Granville Tennis Club Manage Booking</h3>
<br><br><br>
<?php
include "dbconnect.php";
session_start();
$login_ID = $_SESSION['id'];
$query = "SELECT Booking_ID
FROM `booking`
WHERE Login_ID = '$login_ID';";
$bookingArray = array();
$result = $mysqli -> query($query);
while ($row = $result->fetch_assoc()){
printf ("%s<br>", $reference = $row["Booking_ID"]);
array_push($bookingArray, $reference . "<br>");
}
print_r ($bookingArray);
?>
<table border="1" style="width:50%">
<caption>Please select a booking to edit:</caption>
<tr>
<td>
<ul style="list-style-type:circle">
<?php
$arrayNo = 1;
while ($row = $result->fetch_assoc()){
printf ("<li><a href='UpdateBooking.php'>Booking ID:%s</a>" . $bookingArray[$arrayNo] . "</li><br>");
$arrayNo = $arrayNo + 1;
}
?>
<li><a href="UpdateBooking.php">Booking ID</a></li>
</ul>
</td>
</tr>
</body>
</html>
忽略表之前的代碼,這只是供我參考。 – Hooley98