我有一个MySQL数据库,我需要搜索交易号码(并显示我的姓名,电子邮件和item_name)或搜索我的电子邮件地址和名称以及购买日期然后会给我我的交易号和item_name - 除非电子邮件,名称和购买日期都是正确的,否则我不想要任何东西出现。搜索并显示来自SQL数据库的结果
场在我的数据库是:
iname
iemail
itransaction_id
item_name
可能有人请帮助.... 这就是我目前有....
<html>
<head>
<title>Search</title>
</head>
<body bgcolor=#ffffff>
<h2>Search</h2>
<form name="search" method="post" action="findme.php">
Seach for: <input type="text" name="find" />
<input type="submit" name="search" value="Search" />
</form>
</body>
</html>
保存为findme.html
下一个:
<html>
<head><title>Searching for a student...</title>
</head>
<body bgcolor=#ffffff>
<?php
echo "<h2>Search Results:</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term!!!";
exit;
}
// Otherwise we connect to our Database
mysql_connect("xxxx.com", "xxxx", "xxxxpw") or die(mysql_error());
mysql_select_db("xxxx") or die(mysql_error());
// We perform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$iname = mysql_query("SELECT * FROM ibn_table WHERE upper($field) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array($iname))
{
echo $result['firstname'];
echo " ";
echo $result['lastname'];
echo "<br>";
echo $result['idnumber'];
echo "<br>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($iname);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query...<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
//}
?>
</body>
</html>
这是保存为findme.php
这是目前得到的错误IM:
搜索结果:
警告:mysql_fetch_array():提供的参数是不是一个有效的MySQL结果资源/爱马仕/bosweb25a/b409/ipg.bexgroupcouk/silverliningnetworks/Database/findme.php上线31
警告:mysql_num_rows():提供的参数不是在/hermes/bosweb25a/b409/ipg.bexgroupcouk/一个有效的MySQL结果资源silverliningnetworks/Database/findme.php on line 43 所以RRY,但我们无法找到一个条目,以符合您搜索......搜索
为:CARYS
其中是$字段定义(从SQL查询)? – 2013-03-08 07:46:47
请快速搜索您收到的错误消息,您将得到足够多的结果,指出您至少在正确的方向调试问题。 – deceze 2013-03-08 08:00:22
生成的SQL语句是什么? – Raptor 2013-03-08 08:11:10