###前提・実現したいこと
複数の条件の行を違う表として表示させたいのですが、一行も表示されません。
SELECT文を複数回使用する際の文法ミスなどあれば何卒ご教授頂きたく…
###ソースコード
<?php require_once('db_accese.php'); $db = new DB(); $sql_mon = "SELECT * FROM timetable WHERE day=' mon'"; $res_mon = $db->executeSQL($sql,null); //$recordlist = "<table>\n"; $index .= "<table>\n" ."<tr><td>" .'コード' ."</td><td>" .'授業名' ."</td><td>" .'担当者' ."</td><td>" .'雇用形態' ."</td><td>" .'開催時期' ."</td><td>" .'曜日' ."</td><td>" .'時限' ."</td><td>" .'教室' ."</td><td>" .'CD' ."</td><td>" .'CS' ."</td><td>" .'HW' ."</td><td>" .'PS' ."</td>"; while($row = $res_mon->fetch(PDO::FETCH_ASSOC)){ //連想配列を使う場合はFETCH_ASSOCを指定 $recordlist .= "<tr><td>{$row['code']}</td>"; $recordlist .= "<td>{$row['name']}</td>"; $recordlist .= "<td>{$row['teacher']}</td>"; $recordlist .= "<td>{$row['employ']}</td>"; $recordlist .= "<td>{$row['semester']}</td>"; $recordlist .= "<td>{$row['day']}</td>"; $recordlist .= "<td>{$row['term']}</td>"; $recordlist .= "<td>{$row['room']}</td>"; $recordlist .= "<td>{$row['CDgrade']}</td>"; $recordlist .= "<td>{$row['CSgrade']}</td>"; $recordlist .= "<td>{$row['HWgrade']}</td>"; $recordlist .= "<td>{$row['PSgrade']}</td></tr>"; } $recordlist .= "</table>\n"; //火曜日 $sql_tue = "SELECT * FROM timetable WHERE day = ' tue'"; $res_tue = $db->executeSQL($sql_tue,null); while($row = $res_tue->fetch(PDO::FETCH_ASSOC)){ //連想配列を使う場合はFETCH_ASSOCを指定 $recordlist2 .= "<tr><td>{$row['code']}</td>"; $recordlist2 .= "<td>{$row['name']}</td>"; $recordlist2 .= "<td>{$row['teacher']}</td>"; $recordlist2 .= "<td>{$row['employ']}</td>"; $recordlist2 .= "<td>{$row['semester']}</td>"; $recordlist2 .= "<td>{$row['day']}</td>"; $recordlist2 .= "<td>{$row['term']}</td>"; $recordlist2 .= "<td>{$row['room']}</td>"; $recordlist2 .= "<td>{$row['CDgrade']}</td>"; $recordlist2 .= "<td>{$row['CSgrade']}</td>"; $recordlist2 .= "<td>{$row['HWgrade']}</td>"; $recordlist2 .= "<td>{$row['PSgrade']}</td></tr>"; } ?> <!DOCTYPE html> <html> <head> <title>test</title> <meta charset="utf-8"> <style> table tr:hover { background-color: #fff072; } tr:nth-child(1) { background-color:#42f474; } td{border:1px solid black;} </style> </head> <body> <h1>曜日ごとに表示</h1> <?php echo $index;?> <?php echo $recordlist;?><br /> <?php echo $index;?> <?php echo $recordlist2;?><br /> </body> </html>
###補足情報(言語/FW/ツール等のバージョンなど)
各バージョン
php:PHP 5.6
Mysql:Mysql5.5
[mon]を含むデータ
2 授業名 担当者名 PS full 1 mon 4 W207 null null null null null null null null null null null null PSopenY 授業呼称名 1 option null null null null null
tueで表示されるべきデータ例
2 授業名 担当者名 PS full 1 mon 4 W207 null null null null null null null null null null null null PSopenY 授業呼称名 1 option null null null null null
回答4件
あなたの回答
tips
プレビュー