php search script add pagination

Codes here !

Moderators: macek, egami, gesf

MishaAbesadze
New php-forum User
New php-forum User
Posts: 1
Joined: Mon Feb 11, 2013 7:06 am

php search script add pagination

Postby MishaAbesadze » Mon Feb 11, 2013 7:11 am

I want to add pagination on this search script. Please help me

<?php
$button = $_GET ['submitSearch'];
$search = $_GET ['search'];
if(!$button)
echo "<h1>Error</h1>";
else
{
if(strlen($search)<=1)
echo "<h1>Search term too short</h1>";
else{
mysql_connect("localhost","username","password");
mysql_select_db("database");
$search_exploded = explode (" ", $search);
foreach($search_exploded as $search_each){
$x++;
if($x==1)
$construct .="keywords LIKE '%$search_each%'";
else
$construct .="AND keywords LIKE '%$search_each%'";
}
$construct ="SELECT * FROM searchengine WHERE $construct";
$run = mysql_query($construct);
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "<h1>Sorry, there are no result</h1>";
else{
echo "<h1>$foundnum results found!</h1><p>";
while($runrows = mysql_fetch_assoc($run)){
$title = $runrows ['title'];
$desc = $runrows ['description'];
$url = $runrows ['url'];
echo
" <a href='$url'><b>$title</b></a><br>
$desc<br>
<a href='$url'>$url</a><br><br>" ;

}
}
}
}
?>

php9
New php-forum User
New php-forum User
Posts: 13
Joined: Fri Feb 22, 2013 2:20 am

Re: php search script add pagination

Postby php9 » Fri Feb 22, 2013 3:09 am

Are you getting any error messages? Check your PHP error log and post back.


Return to “mySQL & php coding”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest