If this is a problem, you can use always $show = 50; ... for example. This way you will let the visitors choose only the number of records that should be skipped.
But I don't think that this is a problem because either way you do your page, the visitor can create a program using the LWP library and get your pages one by one, then combine them, parse them and steal all the data from them. Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] ----- Original Message ----- From: "Wiggins d'Anconia" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 29, 2003 6:12 AM Subject: Re: How to display multiple web pages depending on Octavian Rasnita wrote: > It is not very hard. > > You can use an sql statement like this: > > my $sth = $dbh->prepare("select id, name, age, bla from table order by name > limit ?, ?"); > $sth->execute($skip, $show); > > You can get the number of rows you want to skip ($skip) and the number of > rows you want to show ($show) using the CGI package like: > > USE CGI; > my $q = new CGI; > my $skip = $q->param('skip'); > my $show = $q->param('show'); > > You can check first the total number of rows that could be displayed, then > you can compare, and if the total number of rows is bigger than the $skip + > $show, meaning the latest record printed in the current page, then you can > print a "Next" link, and ... do the same with the "previous" link.... > > This works well depending on the case. If the fact that you have a lot of data is valuable in itself, or if your server is subject to heavy loads, DOS attacks, etc. then you may not want to provide the method to determine the number to select as an argument as anyone could choose an arbitrarily high number to get all of the data then just use a parser to "steal" your data, or if you have lots of data to overload your db with multiple selects of all of the data, etc. Just something to keep in mind otherwise I like this approach and use something very similar, http://danconia.org > > ----- Original Message ----- > From: "Dennis Stout" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Monday, July 28, 2003 5:39 PM > Subject: Re: How to display multiple web pages depending on > > > >>I want to write a subroutine to select the contain of MySQL database and >>display the result on the browser. >>But I'm not sure how to get it create multiple pages if the list exceeds >>a given number; say 50, and create a link to the next page: like "Next" >>or "1 2 3". I think it should be easy - but I've never seen codes like >>that before. > > > The idea is you create a ranged loop. > > for (x..x+y) { > #blah > } > > #blah is where you put all your code for retrieving lines from the SQL dbase > and HTMLize them and return them. > > x is obtained through CGI params > > my $q = new CGI; > my $start = $q->param('start'); > > x+y is obtained however > > 1- > my $end = $start + $q->param('amount_per_page'); > 2- > my $end = $start + 50; > > whichever. > > Then; > > for ($start..$end) { > #grab from db, htmllize, append to scalar variable... > } > > > print <<EOF; > <center> > <table> > $scalar_from_for_loop > </table> > </center> > EOF > > and, yeah... > > Should put you on the right track. I wrote my own customized interface to > SQL > (actually its an interface to the normal DBI interface, heh..) so I didn't > write that portion since what I use would not at all be like what you would > use. > > Dennis > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]