我從JSON鏈接解析3個變量,每個變量組成一個電影院的名字:php-sql select「where」等於幾個變量?
$cinema1
$cinema2
$cinema3
後,我需要從表中選擇所有3個影院的標識,並使用IDS我需要尋找表格「movietimings」,看看今天是否有電影正在播放,如果今天在電影院播放了電影,那麼我需要去看「電影」表並顯示關於該電影的所有信息。
所以,這就是已經完成:
$sql2 = "SELECT DISTINCT * FROM cinema WHERE cinemaname = '$cinema1' AND cinemaname='$cinema2' AND cinemaname='$cinema3' ";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
// output data of each row
while($row2 = $result2->fetch_assoc()) {
$cinemaid2 = $row2['id'];// I have received a cinema id
//getting the main id, since the id I just got is a branch of the main cinema, so the main id that is associated with movie timings is down below
$sql5 = "SELECT DISTINCT * FROM cinemas WHERE cinemaname = '$cinemaid2'";
$result5 = $conn->query($sql5);
if ($result5->num_rows > 0) {
// output data of each row
while($row5 = $result5->fetch_assoc()) {
$cinemaid = $row5['id'];//received main id required
$today = date("m/d/Y");//getting todays date
//now trying to find if a movie today playing
$sql3 = "SELECT * FROM moviecinemashowsassociation WHERE cinemaid LIKE '$cinemaid' AND showdate LIKE '$today'";
$result3 = $conn->query($sql3);
if ($result3->num_rows > 0) {
// output data of each row
while($row3 = $result3->fetch_assoc()) {
$movieid = $row3['movieid'];// selected a movie id played today
//selecting information about movie
$sql4 = "SELECT * FROM movie WHERE id='$movieid'";
$result4 = $conn->query($sql4);
if ($result4->num_rows > 0) {
// output data of each row
while($row4 = $result4->fetch_assoc()) {
的問題是,我有3個不同的電影院應該經歷一個循環。
定義:「對我們來說不行」。變量的值是...?數據庫模式是什麼? db中的值是什麼? –
你需要學習布爾邏輯。你在說「現場電影漫畫必須同時具備以下所有三個值」。你想要一個'或'。 「可以是以下任何值」 –
感謝您的回覆。 我正在改變這個問題,因爲它似乎我沒有清楚地理解問題。 –