Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #16822

Re: Limit "most popular" to 100

Subject Re: Limit "most popular" to 100
Newsgroups comp.lang.php
References <super70s-BB47CD.10383304072016@boina.datemas.de>
From Richard Damon <Richard@Damon-Family.org>
Message-ID <fQvez.67639$F_5.10789@fx23.iad> (permalink)
Organization Forte - www.forteinc.com
Date 2016-07-04 09:06 -0700

Show all headers | View raw


On 7/4/16 8:38 AM, super70s wrote:
> (This question is for everyone but R.Wieser)
>
> I have a "Most Popular Pages" page on my site, with the page titles and
> brief descriptions listed based on the number of page views. I need to
> limit the number of page titles to 100 instead of having it display
> every single page title in the database, which is what it's doing now. I
> think this is the pertinent code:
>
> <?while ($rshome = mysql_fetch_array($cmdartcat)) { ?>
>
> Is there an easy way to accomplish what I want by modifying this somehow?
>

This is more of a mysql issue than a php issue. If you add a limit cause 
to your query, you can limit how many records you receive.

You could do a php only solution, adding a counter to the loop. 
Something similar to:

<?$cnt=0;
while (++$cnt<=100 && $rshome = mysql_fetch_array($cmdartcat)) { ?>

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Limit "most popular" to 100 super70s <super70s@super70s.invalid> - 2016-07-04 10:38 -0500
  Re: Limit "most popular" to 100 Richard Damon <Richard@Damon-Family.org> - 2016-07-04 09:06 -0700
    Re: Limit "most popular" to 100 "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-04 18:11 +0200
    Re: Limit "most popular" to 100 super70s <super70s@super70s.invalid> - 2016-07-05 22:32 -0500
      Re: Limit "most popular" to 100 "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-07-06 14:02 +0200

csiph-web