<?php
include 'connections.php';
$search = $_POST['searchvalue']; // search value is getting from HTML FORM i.e user entered value
if(strlen($search)>=1)
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
$search_exploded = explode (" ", $search);
$x = "";
$construct = "";
foreach($search_exploded as $search_each)
{
$x++;
if($x==1)
$construct .="title LIKE '%$search_each%'";
else
$construct .="AND title LIKE '%$search_each%'";
}
$construct ="SELECT * FROM books WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum!=0)
while($runrows = mysql_fetch_assoc($run))
{
echo $result; // i have more code to print the result instead i am just using '$result' here.....
}
}
}
?>
上面是显示搜索结果的代码我在我的页面中成功显示结果,但我想每页只显示三个结果。我想为此开发分页,我在stackoverflow和google搜索逻辑分区,但我厌倦了代码我感觉更复杂我根本不理解分页逻辑。请任何人帮助我如何以简单的方式发展分页?而且我不是php的专家,我只是初学者...提前感谢..