3v4l.org

run code in 300+ PHP versions simultaneously
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> <?php session_start(); // セッションを開始 // 管理者かどうかを$_SESSION["user_class"]により確認 // ログインせず直接アクセスした場合(内容未定) if( $_SESSION["user_class"] == ""){ } // 一般ユーザが直接アクセスした場合(内容未定) elseif( $_SESSION["user_class"] == "0"){ } // 管理者がアクセスした場合(以下の処理を開始) elseif( $_SESSION["user_class"] == "1"){ // ホーム画面からイベントIDを引き継ぎ(未完成) //(ホームでも$_SESSION["event_id"]を使ってもらえば再定義不要?) $_SESSION["event_id"] = 002; // 仮の数値 // DB $url = "localhost"; $user = "root"; $pass = ""; $db = "test"; // MySQLへ接続する $link = mysql_connect($url,$user,$pass) or die("MySQLへの接続に失敗しました。"); // データベースを選択する $sdb = mysql_select_db($db,$link) or die("データベースの選択に失敗しました。"); // クエリを送信する // ①イベント名の取得…ホーム画面から引き継いだイベントIDの列を選択、event_nameを取得 $sql = "select event_title from event "; $sql.= "where event_id= " . '$_SESSION["event_id"]' ; $result = mysql_query($sql, $link) or die("クエリの送信に失敗しました。<br/>SQL:".$sql); $row = mysql_fetch_assoc($result); $event_title = $row["event_title"]; // イベントタイトル表示 echo '$_SESSION["event_id"]'; //HTML文を出力 テーブルの開始を指定 print("<table border=1><tr><td></td>"); // 日付 //calenderからdate_idの一致する列を選択 $sql = "SELECT DATE, except FROM calendar "; $sql .="WHERE event_id =002 ORDER BY date_id"; //SQL文を実行する $rs = mysql_db_query($db,$sql); //列数を取得する $num = mysql_num_fields($rs); //選択した列数分だけ繰り返す while($row=mysql_fetch_array($rs)){ //HTML文を出力 日付を <td>で囲んで出力 print("<td>".$row["date"]."</td>"); } //氏名・参加可否 //ユーザID・氏名を取得 $sql ="select user_name from user "; $sql.="order by user_id"; //test表の行数と同じ回数を繰り返す while($row=mysql_fetch_array($rs)){ //HTML文を出力 表の行の開始<tr> を出力 氏名 print("<tr>".$row["user_name"]."</tr>"); //attendからユーザIDの一致する列を取得 $sql ="select attendance from attend "; $sql.="where user_id=".$row["user_name"]; $sql.="order by date_id"; //日数分( と同じ回数)繰り返す  for($j=0;$j<$num;$j++){ //HTML文を出力 列の内容を <td>で囲んで出力+参加可否(0=×、1=△、2=○) print("<td>".$row[$j]."</td>"); } //HTML文を出力 表の改行</tr> を出力 print("</tr>"); } //HTML文を出力 テーブルの終了を指定 print("</table>"); // MySQLへの接続を閉じる mysql_close($link) or die("MySQL切断に失敗しました。"); } //管理者アクセスの動作、ここまで ?> <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 8.3.0 - 8.3.6
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Session cannot be started after headers have already been sent in /in/CJRnN on line 8 Warning: Undefined global variable $_SESSION in /in/CJRnN on line 13 Warning: Trying to access array offset on null in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Session cannot be started after headers have already been sent in /in/CJRnN on line 8 Warning: Undefined global variable $_SESSION in /in/CJRnN on line 13 Warning: Trying to access array offset on value of type null in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 8.0.0 - 8.0.30
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Session cannot be started after headers have already been sent in /in/CJRnN on line 8 Warning: Undefined variable $_SESSION in /in/CJRnN on line 13 Warning: Trying to access array offset on value of type null in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 7.4.0 - 7.4.33
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot start session when headers already sent in /in/CJRnN on line 8 Notice: Undefined variable: _SESSION in /in/CJRnN on line 13 Notice: Trying to access array offset on value of type null in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 7.3.32 - 7.3.33
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot start session when headers already sent in /in/CJRnN on line 8 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot start session when headers already sent in /in/CJRnN on line 8 Notice: Undefined variable: _SESSION in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 7.0.18 - 7.0.33, 7.1.4 - 7.1.33
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/CJRnN:1) in /in/CJRnN on line 8 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CJRnN:1) in /in/CJRnN on line 8 Notice: Undefined index: user_class in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.17, 7.1.0 - 7.1.3
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Notice: Undefined index: user_class in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Notice: Undefined index: user_class in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>
Output for 4.3.0 - 4.3.1
<Html> <Head> <Title>登録状況確認</Title> </Head> <Body> Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cookie - headers already sent by (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Warning: session_start() [http://www.php.net/function.session-start]: Cannot send session cache limiter - headers already sent (output started at /in/CJRnN:7) in /in/CJRnN on line 8 Notice: Undefined index: user_class in /in/CJRnN on line 13 <br> <button type="button" onclick="location.href='top.php'">ホームへ戻る</button> </Body> </Html>

preferences:
292.17 ms | 402 KiB | 460 Q