Hi I have a search program that searches using a "keyword" search parameter. Sometimes the keywords have a space.
My program starts like this.
#!/usr/bin/perl
use CGI;
$req = new CGI;
$keywordpara = $req->param('Keywords');
$datadir = "/home/open(FILE,"$datadir/data.log"
@data = <FILE>;
close(FILE);
print "content-type:text/html\n\n";
$num = @data;
$result=0; $i=0; $j=0; $a=0;
foreach $data (@data) {
($id,$simage,$bimage,$artist,$ref,$size,$desc,$price,$title,$display,$Category,$Keywords) = split(/::/, $data);
if (($artist =~ /\b$keywordpara/i)||($title =~ /\b$keywordpara/i)) {
#if (($Category eq $categorypara)) {
$result++;
}
}
$page = $req->param('page');
if ($page eq '') { $page=0;}
else { $line = $page*6; }
Then prints the data depending on the keywords using this.
foreach $data (@data) {
($id,$simage,$bimage,$artist,$ref,$size,$desc,$price,$title,$display,$Category,$Keywords) = split(/::/, $data);
if (($artist =~ /\b$keywordpara/i)||($title =~ /\b$keywordpara/i)) {
$a++;
if ($a <= $line) {
next;
}
else {
$i++;$j++;
if ($j <= 6) {
if ($i==1) {
print "<tr>";
}
etc...
It works fine for the first search as I have replaced all the spaces in my links with %20
However at the end of the program I have a link to next page section:
print "<CENTER><table><tr><td><span class=\"title\">page - </span> ";
$num_of_page = $result/6;
for($b=0;$b<$num_of_page;$b++)
{
$view = $b+1;
print "<span class=\"cgifoot\"><a class=\"cgilink\" href=\"}
print "</span></td></tr></table></CENTER>";
The problem is that in Netscape even when the URL has the spaces replaced in the keywords with %20 the link to page part of the cgi program (search.cgi?page=$b&Keywords=$keywordpara) is not picking this up and therefore is not displaying the next page results in Netscape.
I'm not very experienced in perl so simple answers would be much appreciated..
Thanks in advance.. Rob
My program starts like this.
#!/usr/bin/perl
use CGI;
$req = new CGI;
$keywordpara = $req->param('Keywords');
$datadir = "/home/open(FILE,"$datadir/data.log"
@data = <FILE>;
close(FILE);
print "content-type:text/html\n\n";
$num = @data;
$result=0; $i=0; $j=0; $a=0;
foreach $data (@data) {
($id,$simage,$bimage,$artist,$ref,$size,$desc,$price,$title,$display,$Category,$Keywords) = split(/::/, $data);
if (($artist =~ /\b$keywordpara/i)||($title =~ /\b$keywordpara/i)) {
#if (($Category eq $categorypara)) {
$result++;
}
}
$page = $req->param('page');
if ($page eq '') { $page=0;}
else { $line = $page*6; }
Then prints the data depending on the keywords using this.
foreach $data (@data) {
($id,$simage,$bimage,$artist,$ref,$size,$desc,$price,$title,$display,$Category,$Keywords) = split(/::/, $data);
if (($artist =~ /\b$keywordpara/i)||($title =~ /\b$keywordpara/i)) {
$a++;
if ($a <= $line) {
next;
}
else {
$i++;$j++;
if ($j <= 6) {
if ($i==1) {
print "<tr>";
}
etc...
It works fine for the first search as I have replaced all the spaces in my links with %20
However at the end of the program I have a link to next page section:
print "<CENTER><table><tr><td><span class=\"title\">page - </span> ";
$num_of_page = $result/6;
for($b=0;$b<$num_of_page;$b++)
{
$view = $b+1;
print "<span class=\"cgifoot\"><a class=\"cgilink\" href=\"}
print "</span></td></tr></table></CENTER>";
The problem is that in Netscape even when the URL has the spaces replaced in the keywords with %20 the link to page part of the cgi program (search.cgi?page=$b&Keywords=$keywordpara) is not picking this up and therefore is not displaying the next page results in Netscape.
I'm not very experienced in perl so simple answers would be much appreciated..
Thanks in advance.. Rob