データベースから Web ページを生成しています。今私の質問は:
データベース(MySql)に1000件のレコード(名前)があります。ページに検索ボックスを作成しました。DB にある名前または名前の一部を入力すると、すべての名前が表示されます。例えば-
SELECT * FROM table where name like '%$find%'
ここで、選択した名前 (クエリを介してフェッチされた) を新しいページに表示して、名前をクリックすると新しいページが開き、その選択した名前に関連するすべてのデータ (に属するテーブルに存在する) を表示したいそのページにナビゲーション ボタンを表示するには、どのクエリを使用すればよいでしょうか。
要するに、自分のページを Google 検索ページのようにしたいのです。
私の最初のページはこんな感じです
<html>
<body >
<h2>Search</h2>
<form name="search" method="post" action="second.php">
Search Name: <input type="text" name="find" id="find" />
<input type="submit" name="search" value="search" />
</form>
</body>
</html>
2ページ目はこんな感じ
<html>
<head>
<script>
function favBrowser()
{
var mylist=document.getElementById("opt");
document.getElementById("favorite").value=mylist.options[mylist.selectedIndex].text;
}
</script>
</head>
<body>
<form method="get">
<?php
$find = $_REQUEST['find'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("data", $con);
$result = mysql_query("SELECT * FROM table where name like '%$find%'");
$result_rows = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
// $names[] = $row['name'];
// echo $names[0];
// echo "$row[name]. $row[id] <a href='data.php?edit=$row[name]'>edit</a><br />";
$_name = $row['name'];
echo "Name : <input type='text' name='name' value='$_name' size='30'>";
echo "<br />";
}
}
mysql_close($con);
?>
<!--</select>
<input type ="submit" value="submit">
<p>Your selected name is: <input type="hidden" name="fun" id="favorite" size="30">
</p>
-->
</body>
</html>