order by time1 ascで予約の早い時間から表示する
<?php $date = date("Y年m月d日"); $week = array( "日", "月", "火", "水", "木", "金", "土" ); $today = $date."(".$week[date("w")].")"; echo "本日の予約状況(".$today.")<hr>"; $dsn = "mysql:dbname=reserve;host=localhost"; $user = "hoge"; $password = "hogehoge"; try { $dbh = new PDO($dsn, $user, $password); } catch (PDOException $e){ print('connection failed:'.$e->getMessage()); } $sql = "select * from masters where day = '".$today."' order by time1 asc"; $stmt = $dbh->query($sql); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach($result as $value){ $t1h = floor($value['time1'] / 60); $t1m = $value['time1'] % 60; if(!$t1m == NUll ){ $t1 = $t1h.":".$t1m; }else{ $t1 = $t1h.":00"; } $t2h = floor($value['time2'] / 60); $t2m = $value['time2'] % 60; if(!$t2m == NUll ){ $t2 = $t2h.":".$t2m; } else { $t2 = $t2h.":00"; } echo $value['charge']. ":".$t1."~".$t2." ".$value['name']."様<br>"; }
ホットペッパーのような〇×のマトリックスを横軸で作りたいですね。
ソースを見ると、普通にtable tr tdのようです。