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: Beginner:
I need help with search results...

 



Jose
Deleted

May 8, 2001, 2:53 PM

Post #1 of 2 (410 views)
I need help with search results... Can't Post

Hello! I'm from Portugal and I'm only a beginner in these questions but I really need help on limitting the number of search results per page. (forgive my english). Can someone help me please? My search script is something like this:

require "config.pl";

$query=<STDIN>;

$url="No Url";
$title="No title";
$description="No description";
$thequery="no query";

$counter=0;

$query=substr($query,6,200);
$query =~ tr/+/&/;
@query_search=split(/&/,$query);

print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD><TITLE>$site_name - Results: </title></head>\n";
print "<body bgcolor=$background>\n";
print "<body text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\">\n";
print "<font face=\"Arial Narrow\" size=\"2\">\n";
print "<center><h4>$site_name - Results: </h4></center>\n";

foreach $thequery (@query_search) {
open(database, "filebase.txt"); # Open the database
while(<database>) {
@fullsearch=split(/&/,$_); # make the query array

foreach(@fullsearch) { # clean up the garbage ;)
tr/+/ /;
s/=/ /;
s/%(..)/pack("C",hex($1))/ge;
}

$url=$fullsearch[0];
$title=$fullsearch[1];
$description=$fullsearch[2];

if(("$title" =~ /$thequery/i) || ($thequery =~ /$url/i) || ("$description" =~ /$thequery/i)) {
$counter++;
if($counter eq $max_results) {
print"<center><h5>Too much results.</h5></center>\n";
}
print "<p>$counter: <a href=$url><b>$title</b></a> - ";
print "$description</p>";
}
}
if ($counter eq 0) {
print "<center><h5>Nothing was found.</h5></center>\n";
}
close database;
}


print "<center><a href=$site_url>[Home]</a>\n";
print "<p align=right <normal>Home</p></normal>\n";
print "</body>";
print "\n</html>";
close;





Pro_4
User

May 8, 2001, 3:02 PM

Post #2 of 2 (409 views)
Re: I need help with search results... [In reply to] Can't Post

Well one thing i noticed was when you opened your database you didnt specify how to open it. Also just kinda a rule of thumb but you need to name the filehandle in upper case only so it wont interfere with any future use of that word.
Since you are reading your database for that info ( i believe) you need to do this:

open (DATABASE, '< filebase.txt' )

Hope that helps a little :)

People Engrossed by a Reliable Language

 
 


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

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