Loading ...
Sorry, an error occurred while loading the content.

Re: [php_greek] pagination. select pages. any idea?

Expand Messages
  • Ntina Triantafilidou
    Hi! Kai egw exw afto to provlima kai o tropos pou prospathisa na to lisw einai o eksis: sou grafw ton php kwdika opws mou erxetai aftin tin stigmi. Page 1:
    Message 1 of 4 , Nov 22, 2005
    • 0 Attachment
      Hi!
      Kai egw exw afto to provlima kai o tropos pou prospathisa na to lisw einai
      o eksis:
      sou grafw ton php kwdika opws mou erxetai aftin tin stigmi.
      Page 1: $query="select * from table where id=>1 and id<10";
      Page 2: $query="select * from table where id=>11 and id<20";
      ....
      Page n: $query="select * from table where id=>10*(n-1)+1 and id<10*n";

      hope this helps!
    • xkorakidis
      Thanks, en merei fainetai na doulevei, alla ti ginetai an den yparxoun ola ta ids? estw px bazeis 50 products k kapoia stigmi sbineis to 9 k to 33, i sto pio
      Message 2 of 4 , Nov 23, 2005
      • 0 Attachment
        Thanks,
        en merei fainetai na doulevei, alla ti ginetai an den yparxoun ola ta
        ids? estw px bazeis 50 products k kapoia stigmi sbineis to 9 k to 33,
        i sto pio akraio, sbineis ta 12-19. Eidika stin teleftaia periptwsi, i
        2i selida 8a dixnei 3 eggrafes! Kati allo pou skeftika einai na
        fortwnetai olos o pinakas ka8e fora k ston pinaka tou result na
        pigainei stin x eggrafi, asxeta id tis. K ekei den kserw ti ginetai
        omws otan prokeitai gia px 30.000 eggrafes, profanws xreiazetai na
        ginei kapoio swap (den mporeis na ta'xeis ola sti mnimi) gia
        apotelesmatiki diaxeirisi tis probolis, opote "run&search" :) Gi' afto
        psaxnw gia kati "typopoiimeno", kati pou exei douleftei idi mias k to
        sygkekrimeno problima einai poly klassiko pleon, opote 8a exw k kati
        xwris polla problimata.
        Thanks pantws...

        --- In php_greek@yahoogroups.com, Ntina Triantafilidou
        <ntina23gr@y...> wrote:
        >
        > Hi!
        > Kai egw exw afto to provlima kai o tropos pou prospathisa na to lisw
        einai
        > o eksis:
        > sou grafw ton php kwdika opws mou erxetai aftin tin stigmi.
        > Page 1: $query="select * from table where id=>1 and id<10";
        > Page 2: $query="select * from table where id=>11 and id<20";
        > ....
        > Page n: $query="select * from table where id=>10*(n-1)+1 and id<10*n";
        >
        > hope this helps!
        >
      • Symeon Charalabides
        Kala sou eipan gia limit & offset. De hreiazetai tipota typopoiimeno, aplos kodikas einai, apla prepei na ton skefteis diaforetika. ... Ara, se endiaferei na
        Message 3 of 4 , Nov 23, 2005
        • 0 Attachment
          Kala sou eipan gia limit & offset. De hreiazetai tipota typopoiimeno, aplos
          kodikas einai, apla prepei na ton skefteis diaforetika.

          > en merei fainetai na doulevei, alla ti ginetai an den yparxoun ola ta
          > ids? estw px bazeis 50 products k kapoia stigmi sbineis to 9 k to 33,
          > i sto pio akraio, sbineis ta 12-19. Eidika stin teleftaia periptwsi, i
          > 2i selida 8a dixnei 3 eggrafes!

          Ara, se endiaferei na xethapseis ta epomena n apotelesmata (opou n o arithmos ton
          apotelesmaton ana selida pou theleis) tou pinaka. Akrivos ayto kanei to LIMIT tis
          MySQL. RTFM.

          Kati allo pou skeftika einai na
          > fortwnetai olos o pinakas ka8e fora k ston pinaka tou result na
          > pigainei stin x eggrafi, asxeta id tis. K ekei den kserw ti ginetai
          > omws otan prokeitai gia px 30.000 eggrafes, profanws xreiazetai na
          > ginei kapoio swap (den mporeis na ta'xeis ola sti mnimi) gia
          > apotelesmatiki diaxeirisi tis probolis, opote "run&search" :)

          To LIMIT pigainei stin x eggrafi kai sou stelnei ta epomena n apotelesmata horis
          na fortonei ton ypoloipo pinaka, opote den yparhei provlima.

          Gi' afto
          > psaxnw gia kati "typopoiimeno", kati pou exei douleftei idi mias k to
          > sygkekrimeno problima einai poly klassiko pleon, opote 8a exw k kati
          > xwris polla problimata.

          To mono pou hreiazetai na kaneis einai:

          Page 1: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT 0, n
          Page 2: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT n, n
          Page 3: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT 2n, n

          Ayto einai gia hardcoding. Alla poses tetoies selides yparhoun? Profanos oses
          eggrafes ehei o pinakas dia tou n (kai stroggylopoieis ston epomeno akeraio).
          Giati, loipon, na mi valeis tin PHP na sou kanei ayti ti douleia?

          # Poses synolika eggrafes ehei o pinakas?
          $tl=mysql_num_rows(mysql_query('SELECT ... FROM ... WHERE ...'));

          # $top einai o arithmos ton selidon, $n apotelesmata ana selida
          $top=ceil($tl/$n);

          # Gia kathe selida, $newstart tha einai i proti metavliti meta to LIMIT
          for ($i=1; $i<=$top; $i++) {
          $newstart=($i-1)*$n;

          # An vriskomaste se ayti ti selida, de theloume hyperlink
          if ($st==$newstart) print $i;

          # Gia oles tis alles, theloume hyperlink
          else print '<A HREF=page.php?st='.$newstart.'>'.$i.'</A>';

          # An den einai to teleytaio apotelesma, ta horizoume me "|"
          $i==$top or print ' | ';
          }

          Meta, arkei na kaneis to exis query gia kathe selida:

          SELECT ... WHERE ... [WHERE ...] [ORDER BY ...] LIMIT $st, $n)

          Kai teleioses. A, sto paradeigma hrisimopoio metavliti anti gia stathera gia to
          $n, giati to pira apo to http://www.systasis.com/e-cards.php opou epitrepo sto
          hristi na epilexei to $n pou tou aresei.

          Elpizo na voithisa. An hreiazesai peraitero voitheia sti diadikasia, steile
          prosopiko.


          PS: Grafe greeklish, please. De diavasa to proto sou e-mail giati svyno ta
          ellinika aytomata (to Pegasus de ta katalavainei) kai an den itan to email tis
          Dinas, de tha eiha parei habari to thema.


          Symeon Charalabides (cosmopolite trainee)
          -------------------------------------------------
          http://www.systasis.com
        • xkorakidis
          eyxaristw file, 8a to dokimasw. mou steilan k kati alla pou einai psilomegala, k katebasa k ena allo (pager) alla den prolaba na ta dokimasw akomi. tha to exw
          Message 4 of 4 , Nov 23, 2005
          • 0 Attachment
            eyxaristw file, 8a to dokimasw.
            mou steilan k kati alla pou einai psilomegala, k katebasa k ena allo
            (pager) alla den prolaba na ta dokimasw akomi.
            tha to exw ypopsin mou gia ta greeklish,
            thanks!

            --- In php_greek@yahoogroups.com, "Symeon Charalabides" <symeon@s...>
            wrote:
            >
            > Kala sou eipan gia limit & offset. De hreiazetai tipota
            typopoiimeno, aplos
            > kodikas einai, apla prepei na ton skefteis diaforetika.
            >
            > > en merei fainetai na doulevei, alla ti ginetai an den yparxoun ola ta
            > > ids? estw px bazeis 50 products k kapoia stigmi sbineis to 9 k to 33,
            > > i sto pio akraio, sbineis ta 12-19. Eidika stin teleftaia periptwsi, i
            > > 2i selida 8a dixnei 3 eggrafes!
            >
            > Ara, se endiaferei na xethapseis ta epomena n apotelesmata (opou n o
            arithmos ton
            > apotelesmaton ana selida pou theleis) tou pinaka. Akrivos ayto kanei
            to LIMIT tis
            > MySQL. RTFM.
            >
            > Kati allo pou skeftika einai na
            > > fortwnetai olos o pinakas ka8e fora k ston pinaka tou result na
            > > pigainei stin x eggrafi, asxeta id tis. K ekei den kserw ti ginetai
            > > omws otan prokeitai gia px 30.000 eggrafes, profanws xreiazetai na
            > > ginei kapoio swap (den mporeis na ta'xeis ola sti mnimi) gia
            > > apotelesmatiki diaxeirisi tis probolis, opote "run&search" :)
            >
            > To LIMIT pigainei stin x eggrafi kai sou stelnei ta epomena n
            apotelesmata horis
            > na fortonei ton ypoloipo pinaka, opote den yparhei provlima.
            >
            > Gi' afto
            > > psaxnw gia kati "typopoiimeno", kati pou exei douleftei idi mias k to
            > > sygkekrimeno problima einai poly klassiko pleon, opote 8a exw k kati
            > > xwris polla problimata.
            >
            > To mono pou hreiazetai na kaneis einai:
            >
            > Page 1: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT 0, n
            > Page 2: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT n, n
            > Page 3: SELECT ... FROM ... [WHERE ...] [ORDER BY ...] LIMIT 2n, n
            >
            > Ayto einai gia hardcoding. Alla poses tetoies selides yparhoun?
            Profanos oses
            > eggrafes ehei o pinakas dia tou n (kai stroggylopoieis ston epomeno
            akeraio).
            > Giati, loipon, na mi valeis tin PHP na sou kanei ayti ti douleia?
            >
            > # Poses synolika eggrafes ehei o pinakas?
            > $tl=mysql_num_rows(mysql_query('SELECT ... FROM ... WHERE ...'));
            >
            > # $top einai o arithmos ton selidon, $n apotelesmata ana selida
            > $top=ceil($tl/$n);
            >
            > # Gia kathe selida, $newstart tha einai i proti metavliti meta to LIMIT
            > for ($i=1; $i<=$top; $i++) {
            > $newstart=($i-1)*$n;
            >
            > # An vriskomaste se ayti ti selida, de theloume hyperlink
            > if ($st==$newstart) print $i;
            >
            > # Gia oles tis alles, theloume hyperlink
            > else print '<A HREF=page.php?st='.$newstart.'>'.$i.'</A>';
            >
            > # An den einai to teleytaio apotelesma, ta horizoume me "|"
            > $i==$top or print ' | ';
            > }
            >
            > Meta, arkei na kaneis to exis query gia kathe selida:
            >
            > SELECT ... WHERE ... [WHERE ...] [ORDER BY ...] LIMIT $st, $n)
            >
            > Kai teleioses. A, sto paradeigma hrisimopoio metavliti anti gia
            stathera gia to
            > $n, giati to pira apo to http://www.systasis.com/e-cards.php opou
            epitrepo sto
            > hristi na epilexei to $n pou tou aresei.
            >
            > Elpizo na voithisa. An hreiazesai peraitero voitheia sti diadikasia,
            steile
            > prosopiko.
            >
            >
            > PS: Grafe greeklish, please. De diavasa to proto sou e-mail giati
            svyno ta
            > ellinika aytomata (to Pegasus de ta katalavainei) kai an den itan to
            email tis
            > Dinas, de tha eiha parei habari to thema.
            >
            >
            > Symeon Charalabides (cosmopolite trainee)
            > -------------------------------------------------
            > http://www.systasis.com
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.