CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Displaying Search Results

 



Rab
Deleted

Jul 19, 2000, 5:21 AM

Post #1 of 3 (240 views)
Displaying Search Results Can't Post

Hi-
I need the code that displays the first x entries of a db search query e.g Shows first 10,then click NEXT to see next 10 etc...

I had it some-where but I'm blowed if I can find it !
TIA

Mike


computersmarts
Deleted

Jul 25, 2000, 7:42 AM

Post #2 of 3 (240 views)
Re: Displaying Search Results [In reply to] Can't Post

I don't know how your database is set up but this is some code that I whipped up real quick. I hope it helps a little, but it will need some customization. If this does help a little and you want me to continue the code toward your database email me in more detail about your database and I wil lsee what I can do .... I hope this gives you a start..
################################

@pairs = split(/&/, $ENV{'QUERY_STRING'});

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$QUERY{$name} = $value;

}
####################################
# parrse query

$search = $QUERY{'search'};
$page = $QUERY{'page'};
####################################
# assigning variables

if ($page eq "") { $page = "1"; }
####################################
#if page is blank it will display page 1 as default

$start_at = (10 * $page);
####################################
# This will give you the number
# to start at while pulling results
# from your database, you can change the variable
# to show more results per page.


####################################
# put our database code here mixing in
# the $start_at variable with your code
# I don't know how your database is set up
# so I can't help you here.

####################################
# Below is what your next and previous
# linking text should look like
# you subtract a page for previous
# results and add a page for next results
# of cource you will have to do an if/else
# statement to make sure there is a next and previous
# page to go to. Again I don't know
# the style of your database so I can't customize this help

# previous = <a href="THISSCRIPT.CGI?search=$search&page=$page-1~; }
# next = <a href="THISSCRIPT.CGI?search=$search&page=$page+1~; }



------------------
=========================
Matthew Miller
ComputerSmarts.net
"Linking the Smartest People on the Internet."




Rab
Deleted

Jul 25, 2000, 8:02 AM

Post #3 of 3 (240 views)
Re: Displaying Search Results [In reply to] Can't Post

Many thanks Matthew....will have a look at the code tomorrow ,I'm just finishing for the day......
Mike

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives