我有一个搜索引擎,它从 mysql 数据库中获取链接和标题,并将它们循环到与用户输入相匹配的页面中。它本质上是一个查询,我想知道如何创建一个标记来计算 a)返回的行数和 b)查询返回结果所需的时间。有任何想法吗?
例如,如果我输入“谷歌”,搜索引擎会返回“谷歌”的结果,但是,在结果上方,我希望它显示查询花费了多长时间,大约 4 位小数和多少行正在显示。
$query = " SELECT * FROM scan WHERE ";
$terms = array_map('mysql_real_escape_string', $terms);
$i = 0;
foreach ($terms as $each) {
if ($i++ !== 0){
$query .= " AND ";
}
$query .= "keywords LIKE '%{$each}%'";
}
// Don't append the ORDER BY until after the loop
$query .= "ORDER BY rank";
$query = mysql_query($query) or die('MySQL Query Error: ' . mysql_error( $connect ));
$numrows = mysql_num_rows($query);
if ($numrows > 0) {
if ($k == "Paralympics 2012" ) {
echo "<h1> Paralympic Event: Archery </h1>";
}
if ($k == "paralympics 2012") {
echo "<h1> Paralympic Event: Archery </h1>";
}
while ($row = mysql_fetch_assoc($query)) {
$id = $row['id'];
$title = $row['title'];
$description = $row['description'];
$keywords = $row['keywords'];
$link = $row['link'];
$rank = $row['rank'];