PHP搜索引擎脚本 [英] php search engine script
本文介绍了PHP搜索引擎脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?php
ini_set('display_errors', 0);
$search = $_GET ['search'];
mysql_connect("localhost", "root", "gokul");
mysql_select_db("search123");
$query = mysql_query("SELECT * FROM search WHERE name LIKE '%" . $queryString . "%'");
$foundnum = mysql_num_rows($query);
if ($foundnum == 0) {
echo "Sorry, there are no matching result for <b>$search</b>.</br></br>1.
Try more general words. for example: If you want to search 'how to create a website'
then use general keyword like 'create' 'website'</br>2. Try different words with similar
meaning</br>3. Please check your spelling<br/>4.PLEASE DON'T USE SPACES";
}
else {
echo "$foundnum results found !<p>";
$row = mysql_fetch_assoc($query);
{
$title = $runrows ['title'];
$desc = $runrows ['description'];
$url = $runrows ['url'];
echo "<a href=$row[url]>$row[name]</a><br><font color=green>$row[url]</font><br>$row[desc]<br/>";
}
}
?>
这是我的搜索引擎脚本.该脚本仅显示一个结果.如何使用php更改它以显示大量结果
This is my search engine script. This script only show one result. How to change it to show multy results using php
推荐答案
更改为:
while ($row = mysql_fetch_assoc($query)) {
$title = $runrows ['title'];
$desc = $runrows ['description'];
$url = $runrows ['url'];
echo "<a href=$row[url]>$row[name]</a><br><font color=green>$row[url]</font><br>$row[desc]<br/>";
}
这篇关于PHP搜索引擎脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文