前提・実現したいこと
きり漫様の参考サイトhttps://www.suzuco.net/entry/php-search/の情報をもとに、
phpでDB(mysql)を検索して、検索結果を表示したい。
ただし、きり漫様の参考サイトに対し、DBに項目「htps」を追加し、テーブル内に設定したiframeに「htps」の検索値URLを挿入し、URLのサイトを表示したいが、うまく表示できません。
発生している問題・エラーメッセージ
DBに登録した項目「htps」のURLが検索結果に表示されない
該当のソースコード
<div class="col-xs-6 col-xs-offset-3"> <?php //③取得データを表示する ?> <?php if (isset($userData) && count($userData)) : ?> <p class="alert alert-success"><?php echo count($userData) ?>件見つかりました。</p> <table class="table"> <thead> <tr> <th>名前</th> <th>性別</th> <th>年齢</th> <th>htps</th> </tr> </thead> <tbody> <?php foreach ($userData as $row) : ?> <tr> <td><?php echo htmlspecialchars($row['name']) ?></td> <td><?php echo htmlspecialchars($row['sex'] == 1 ? '男性' : '女性') ?></td> <td><?php echo htmlspecialchars($row['age']) ?></td> <td><iframe src = " + $row['htps'] + " width="400" height="400"></iframe></td> </tr> <?php endforeach; ?> </tbody> </table> <?php else : ?> <p class="alert alert-danger">検索対象は見つかりませんでした。</p> <?php endif; ?> </div>
試したこと
<td><iframe src = " + $row['htps'] + " width="400" height="400"></iframe></td>
上記 「src = " + $row['htps'] + "」の様にしましたが、機能しませんでした。
ただ、個別のURL(例えば、src = "https://www.netcommons.org/") にすると、iframe内にサイトは表示される。
補足情報(きり漫様の参考サイトの流れ)
きり漫様の参考サイトの流れは
①DBに名前、性別、年齢の項目を登録
②検索画面で名前などで検索
③検索結果を表示する(該当のソースコードとして掲載しています)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/09/06 00:35
2019/09/06 00:36