我有2個表,1個表中有一個電影中所有劇集的列表,另一個表中有來自這個劇集的流。每集都有他自己的id,所以流通過該集的id鏈接。立即提取2個查詢
但現在我有一個問題:我想創建一個劇集列表,並在同一時間我想插入一個鏈接到流。所以這意味着我必須同時獲取兩張表格,但我不知道如何。這是我的代碼
<?php
include 'connection.php';
$a = (int)$_GET['a'];
if ($result = $con->prepare("SELECT id, ep_nr, ep_title FROM anime_episode WHERE ani_id = $a"))
{
$result->execute();
$result->bind_result($eid, $nr, $title);
while ($result2 = $con->prepare("SELECT * FROM anime_stream WHERE ep_id = $eid"))
{
$result2->execute();
$result2->bind_result($eid, $etitle, $lang, $sname, $link, $uploadedby);
echo '<div id="list-box">';
echo '<table cellspacing="0">';
while ($result->fetch() && $result2->fetch())
{
echo '<tr>';
echo '<td width="50">' . $nr . '</td>' . '<td>' . $title . '</td>' . '<td>' . $link. '</td>';
echo '</tr>';
}
echo '</div>';
echo '</table>';
}
}
$con->close();
?>
請參閱JOIN。 – Strawberry