這是我在工作正常的那一刻代碼:我有這個代碼是工作正常,但我想將其代碼轉變爲另一種結構
<?php
$sql = "SELECT * FROM te_events order by eventTitle ASC ";
$result = $conn->query($sql);
while($row = $result->fetch_assoc())
{
$venueID = $row['venueID'];
$catID = $row['catID'];
$sql2 = "SELECT * FROM te_venue where venueID='$venueID'";
$result2 = $conn->query($sql2);
while($row2 = $result2->fetch_assoc())
{
$venueName = $row2['venueName'];
}
$sql3 = "SELECT * FROM te_category where catID='$catID'";
$result3 = $conn->query($sql3);
while($row3 = $result3->fetch_assoc())
{
$catName = $row3['catDesc'];
}
?>
但我想將其更改爲這種格式。我只能做到這一點不能超過這個我得到的錯誤。
<?php
$sql ="SELECT eventTitle, eventID, venueID, catID, eventStartDate, eventEndDate, eventPrice FROM te_events ORDER BY eventTitle ASC";
$queryresult = mysqli_query($conn, $sql) or die(mysqli_error($conn));
while ($row = mysqli_fetch_array($queryresult)) {
$venueID = $row['venueID'];
$catID = $row['catID'];
$venueName = $row['venueName'];
$catName = $row['catDesc'];
?>
我該怎麼做呢?
我該如何加入兩張桌子?
我該怎麼做呢? –
我如何加入兩張桌子? –
沒有代碼的問題對未來的訪問者無效。請保留問題中的代碼。如果有一些安全數據(我沒有看到),則應該在服務器上重置它,因爲它已經被暴露。 – chris85