Reply LinkBack Thread Tools Search this Thread
Old 18-06-2008, 14:29   #1 (permalink)
pesokow
How do I mine for fish?!
 
pesokow's Avatar
 
Join Date: May 2008
Posts: 6
Having a problem with search results page!

I'm having a problem with my results page, I found a free search system. The problem is it doesn't show more than 4 results, in fact I don't want it to, I want it to show pages but it doesn't show any more than 1 page! Can someone please show me how to?

There is the code;

PHP Code:
<?php
error_reporting
(E_All);

if(isset(
$_POST['search_text']) || isset($_GET['search_text'])){

        if(isset(
$_GET['search_text']))
           
$search_txt $_GET['search_text'];
        else
             
$search_txt $_POST['search_text'];

        
//alpha clean, then wrap for sql
        
$clean_search preg_replace('/[^\w\s]+/','',$search_txt);
        
$search_list explode(' ',$clean_search);
        if(
count($search_list) > 1){
                
$where_list implode('","',$search_list);
                
//$where_list = substr($where_clause,0,strlen($where_clause)-1);
        
}
        else
        {
                 
$where_list $search_list[0];
        }
        
        
        
$sql_count 'SELECT count(*) FROM search_data WHERE keyword IN ("'.$where_list.'") GROUP BY link';
        
//echo $sql_count;
        
include('dbcreds.php');
        
        
$rs_count mysql_query($sql_count);
        
$total_results mysql_num_rows($rs_count);
        
$row_count 10;

        if (!(isset(
$_GET['pagenum'])))
              
$pagenum 1;
        else
             
$pagenum $_GET['pagenum'];

//This tells us the page number of our last page
$last ceil($total_results/$row_count);

//this makes sure the page number isn't below one, or more than our maximum pages
if ($pagenum 1)
{
$pagenum 1;
}
elseif (
$pagenum $last)
{
$pagenum $last;
}

//This sets the range to display in our query
$max 'limit ' .($pagenum 1) * $row_count .',' .$row_count;    
$sql_sponsored 'SELECT link,description,title FROM search_data WHERE sponsored = 1 AND keyword IN ("'.$where_list.'") GROUP BY link LIMIT 3';    
$sql 'SELECT link,description,title FROM search_data WHERE keyword IN ("'.$where_list.'") GROUP BY link '.$max;
        
    
        
        
        
$rs mysql_query($sql_sponsored);
        if(
mysql_num_rows($rs)>0){
                echo 
'<div style="width:100%;background-color:#DCDCDC;border-top:1px solid #A9A9A9;border-bottom:1px solid #A9A9A9"><b>Sponsored Results</b></div><br>';
                
$j =1;
            while(
$line mysql_fetch_assoc($rs)){
                include(
'results_stub.tpl');
                
$j++;
                }                                            
        }
        echo 
'<br><div style="width:100%;background-color:#DCDCDC;border-top:1px solid #A9A9A9;border-bottom:1px solid #A9A9A9"><b>Web Site Results</b>- Found '.$total_results.' sites for '.$clean_search.'</div>';
        

        if(
$total_results >0){
        
$rs mysql_query($sql);
        
$j =1;
        while(
$line mysql_fetch_assoc($rs)){
                include(
'results_stub.tpl');
                
$j++;
        }
    
        }
        else{
                 echo 
"Perhaps try a different search <a href=\"search.php\">Back</a>";
        
        }
        if(
$last != 1){
                         echo 
'Pages: ';
                         for(
$i=1;$i<($last+1);$i++){
                                 echo 
'<a href="?search_text='.$search_txt.'&pagenum='.$i.'">'.$i.'</a> | ';                                         
                         }
        }
        
        
}


?>

Last edited by pesokow : 18-06-2008 at 14:44.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8