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: Advanced:
How Can I Display Search Results 10 By 10

 



webhay
Novice

Dec 4, 2000, 6:46 AM

Post #1 of 3 (905 views)
How Can I Display Search Results 10 By 10 Can't Post

i Write Search engen Search in CSV File Put I cant Display Search Results 10 By 10.Like
Prev 10 - Next 10

please help


------------------
Haytham Taher


sleuth
Enthusiast

Dec 4, 2000, 11:05 PM

Post #2 of 3 (905 views)
Re: How Can I Display Search Results 10 By 10 [In reply to] Can't Post

 
It's a little complex if you consider the next & prev buttons, it's a pain to me anyway, hehe,

Basically it's like this,

You loop through the data:

open(file, "<file.cvc");
while(<file> )
{
(@res)=split(/\|/, $_);
}
close(file);

K, now that you have looped through it, count each line by adding $var++;

open(file, "<file.cvc");
while(<file> )
{
(@res)=split(/\|/, $_);
$c++;
}
close(file);

Now you can say, if ($c > 0 && $c < 11){
print "Results 1-10";
}

Totalling up too,

open(file, "<file.cvc");
while(<file> )
{
(@res)=split(/\|/, $_);
$c++;
if ($c > 0 && $c < 11){
print "Results 1-10";
}
}
close(file);

See what I mean? Then for the next button, you want to pass the variable that's going to be 10 + what was the last set of results, like if your on 1 - 10, then add 10 to 10 to get 20 and pass that to the script and instead of $c < 10 do $c < $var and $var will be what you passed to the script.

Getting to complicated I know, ok,

Script:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if (!$in{'start'}){
#nothing defined for beinging, use 0
$being = 0;
}else{
$begin = $in{'start'};
}
## Get ending number
if (!$in{'end'}){
#end not defined, use 10
$end = 10;
}
else{
$end = $in{'end'};
}
###########
# Determine beginning & end for next button
###########
$next_end = $end + 10;
$next_begin = $begin + 10;
###########
open(file, "<file.cvc");
while(<file> )
{
(@res)=split(/\|/, $_);
$c++;
if ($c > $begin && $c < $end){
print "Results 1-10";
}
}
close(file);
if ($next_end > $c){
#$next_end is greater than the number of records found, make it the same number
$next_end = $c;
}
# for next button, pass $next_end & $next_beginning to the script. via link
</pre><HR></BLOCKQUOTE>

See what I'm getting at,

Sleuth

P.S. Sorry 4 being to fast, but I'm really tired.


jack.chicrac
Deleted

Dec 5, 2000, 5:29 AM

Post #3 of 3 (905 views)
Re: How Can I Display Search Results 10 By 10 [In reply to] Can't Post

try to follow me :

you have an array like :
@results
you take the number of reference in :
$number = @results

say that you have 122 referneces in this array

now take a display number, here 10
$display = 10;

now you must to determine how it display :
$first = $display * $page
here it's 10*1 = 10
$last = $first + $display

and now the boucle

for x=$first;x<$last;$x+1

etc.....

you just have to pass the page number...

 
 


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

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