Welcome, Guest. Please login or register.

Login with username, password and session length
February 06, 2012, 02:03:19 AM
[Less]
  • News: ATokar.net 3.0 has been released! Click here for more info.

  •  
linktree ATokar.net  >  Coding  >  PHP
linktree Topic: search results
Pages: [1]   Go Down
  Print  
Author Topic: search results  (Read 1322 times)
0 Members and 1 Guest are viewing this topic. Bookmarked by 0 members.
vaunce
Karma: +0/-0
Offline Offline

Gender: Male
Posts: 1



« on: June 17, 2009, 02:30:33 PM »

I am working on a script, simple really, that is pulling up top 10 results of same query from 5 different search engines. removes a duplicates and rates the results base on duplication and placement.
The logical problem that I have is with display of the results on page 2,3...
I am not sure how to list the sites and when you run a second query without cashing original results. can this even be done?
Logged
Cleo
Administrator
Developer
Karma: +6/-0
Offline Offline

Gender: Male
Posts: 172




WWW
« Reply #1 on: June 17, 2009, 11:15:49 PM »

First, you need to count the results.

Then you need to have the results in an array, and for example, do something like:

Code: [Select]
<?php
$results 
= array(
    
=> 'first',
    
=> 'second',
    
=> 'third',
    
=> 'fourth',
    
=> 'fifth',
    
=> 'sixth',
    
=> 'seventh',
    
=> 'eight',
    
=> 'ninth',
    
=> 'tenth',
    
10 => 'eleventh'
);

$per_page 5;
$result_count count($results);

$start 0;

if (isset(
$_GET['start']) && $_GET['start'] > && $_GET['start'] < $result_count)
    
$start = (int) $_GET['start'];

$j 0;
for (
$i $start$i $result_count$i++)
{
    echo 
$results[$i], '<br>';
$j++;

    if (
$j >= $per_page)
        break;
}

if (
$start >= $per_page)
    echo 
'<br><a href="?start='$start $per_page'">Previous</a>';

if (
$result_count $start $per_page)
    echo 
'<br><a href="?start='$start $per_page'">Next</a>';

?>


I have tested the above code and it appears to do what it should. :)
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  


Copyright © 2007–2010 ATokar.net. All trademarks are property of their respective owners.
Powered by SMF | SMF © 2006–2007, Simple Machines LLC
Page created in 0.091 seconds with 27 queries.
Contact Us - ATokar.net - XML - Sitemap - Top
Valid HTML 4.01! Valid CSS! Valid RSS! Powered by Linux Powered by MySQL Powered by PHP Powered by Apache 2.2