Hi I need some help within pagination here is the code I'm been using
sub loadArticleSelection { $lang = $query->param("lang") ; my $country_swiss = $query->param("country_swiss"); my $country_france = $query->param("country_france"); my $with_lang_french = $query->param("with_lang_french"); my $with_lang_german = $query->param("with_lang_german"); my $with_lang_italian = $query->param("with_lang_italian"); my $with_lang_english = $query->param("with_lang_english"); my $cat = shift || ''; my $type = shift || ''; my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtim +e(); my $date = sprintf "%4d-%02d-%02d \n",$year+1900,$mon+1,$mday; my $depot = $query->param("depot"); $depot =~ s/[^A-Za-z0-9 ]/; my $string = ""; my $index = '0'; my $total = '0'; my $add; my $add2; my $dep; if ($country_swiss eq '1') { $add .= "AND article.ref_pays = 1"; } if ($country_france eq '1') { if ($country_swiss) { $add .= "OR article.ref_pays = 2"; }else { $add .= "AND article.ref_pays = 2"; } } if ($type) { $add2 = "AND id_categorie = '$type'"; } else { $add2 = ""; } if ($depot) { $dep = "AND ref_depot = (SELECT id_depot FROM depot WHERE ville = +'$depot')"; } my ($c)= $mydb->sqlSelectMany("DISTINCT article.nom,marque,label, +prix, pochette", "article,met_en_vente", "ref_article = id_article AND met_en_vente.notre_select +ion = '1' AND ref_statut = '3' AND article.quantite > 0"); while( ($ARTICLE{'name'},$ARTICLE{'author'},$ARTICLE{'label'},$ART +ICLE{'price'},$ARTICLE{'pochette'},$ARTICLE{'genre'})=$c->fetchrow()) + { $total +=1; } my $nb_page = arrondi ($total / 40, 1); my $min_index = '0'; my $max_index = '40'; #print "Content-Type: text/html\n\n"; for (my $i = '0'; $i < $nb_page + 1;$i++) { #my $x = my $j; #print "valeur de i $i <br />"; if ($i <= 9) { $j = "0$i"; }else { $j = $i; } $string .= "<a href=\"/cgi-bin/recordz.cgi?lang=$lang&amp;page=mai +n&session=$session_id&amp;min_index_our_selection=$min_index&amp;max_ +index_our_selection=$max_index&amp;country_swiss=$country_swiss&amp;c +ountry_france=$country_france&amp;with_lang_french=$with_lang_french& +with_lang_german=$with_lang_german&amp;with_lang_italian=$with_lang_i +talian&amp;with_lang_english=$with_lang_english\" ><-$j-></a>&#160;&n +bsp;"; $min_index += 40; } if (($nb_page % 10) > 0) { $string .= "<br/>"; } return $string; } sub arrondi { my $n = shift || ''; my $arrondi = sprintf("%.0f", $n); return $arrondi; }
Thanks for your help

In reply to Need help with pagination by *alexandre*

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.