MYSQL搜索问题

时间:2011-08-02 15:38:45

标签: mysql search

     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="text/html; charset=uft8_general_ci" http-equiv="Content-Type" />
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" />
<link href="css/style.css" rel="stylesheet" media="screen" type="text/css" />
<script src="javascript/functions.js" type="text/javascript"></script>
<title>Myhalal Check</title>
<meta content="keyword1,keyword2,keyword3" name="keywords" />
<meta content="Description of your page" name="description" />







</head>

<body class="list">

<div id="topbar"class="black">
<div id="title">
        <span style="color: #ff006f; ">my</span>hala<span style="color: #fff70a; ">check</span></div>
<div id="rightnav">
        <a href="About.html">About</a>

</div>
<div id ="leftnav">
<a href="Submit.html">Submit</a>
</div>
</div>
<div class="searchbox">
    <form action="Search.php" method="get">
        <fieldset><input name="search" id="search" placeholder="Search for a Product" type="text" />
        <input id="submit" type="hidden" name="search" /></fieldset>
    </form>

</div>
<div id="content">
<ul>        
<?php
$search = $_GET['search'];

$host = "x"; 
$user = "x"; 
$pass = "x"; 
$db = "x";

mysql_connect($host, $user, $pass); 
mysql_select_db($db); 
unset($host,$user,$pass,$db); 



//$query = "SELECT produkt FROM checklist WHERE id LIKE '1'";
$query = "SELECT produkt FROM checklist WHERE id LIKE '%$search%'";  
$result = mysql_query($query); 
  while ($row = mysql_fetch_array($result)) 
{ 

echo "<li><span class='name'><b>$row[produkt]";
  }  
?>
</ul>   
</div>
<div id="footer">You could <b><a href="Submit.html"><span style="text-decoration: "><span style="color: #ff006f; ">su</span>bm<span style="color: #fff70a; ">it</span>
</a>
 </b>more Products to help us.
    </div>

</body>

</html>

错误地删除我的最后一个问题后,这又是一次 目前,如果我打开页面,它会给我数据库中的所有信息,最后我只想查看我搜索的产品......任何人都可以帮助请:(变得非常沮丧

1 个答案:

答案 0 :(得分:2)

您的<input>标记没有name属性,因此它不会在$_GET中填充任何键。

name="search"添加到输入标记,然后$_GET['search']将包含您搜索的内容。

您混淆了idname的含义/目的。 id只是为javascript / CSS提供了一个目标,它不会成为表单数据的一部分。