<title>検索結果画面</title> </head> <body> <h1>検索結果</h1> <table border=1> <tr> <th>名前</th> <th>生年</th> <th>種別</th> <th>登録日時</th> </tr> <?php //タイプが何も入力されなかった時に、nullを空文字に変換 ロジックはわからない //$_POST['type']がundefindの時のエラー処理 error_reporting(E_ALL ^ E_NOTICE); $result = serch_profiles($_POST['name'], $_POST['year'], $_POST['type']); foreach ($result as $value) { ?> <tr> <td><a href="<?php echo RESULT_DETAIL; ?> ?id=<?php echo $value['userID']; ?> "><?php echo $value['name']; ?> </a></td> <td><?php echo $value['birthday'];
<table border=1> <tr> <th>名前</th> <th>生年</th> <th>種別</th> <th>登録日時</th> </tr> <?php $result = null; if (empty($_GET['name']) && empty($_GET['year']) && empty($_GET['type'])) { $result = serch_all_profiles(); } else { if (isset($_GET['type'])) { $result = serch_profiles($_GET['name'], $_GET['year'], $_GET['type']); } else { $result = serch_profiles($_GET['name'], $_GET['year']); } //typeの値がなかった場合にserch_profiles()へ不要な引数を渡さないように修正 } foreach ($result as $value) { ?> <tr> <td><a href="<?php echo RESULT_DETAIL; ?> ?id=<?php echo $value['userID']; ?> "><?php echo $value['name']; ?>