Results 1 to 6 of 6
  1. #1
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    This is probably an easy question to answer. I am using the below code to disply the result of certian fields in a mysql database. I want to limit what it display to the first 25 records. However, I have tried to limit the records using the below code, what it does is repeat the first record 25 times. What do I have to do to get it to continue down the database. Any help will be greatly appreciated!

    $rowcount = 1;
    do {
    Echo "<strong>$department </strong> ---> $brandname<br>\n";
    $rowcount++;
    } while ($rowcount < 25);
    continue;

  2. #2
    ABW Veteran Student Heyder's Avatar
    Join Date
    January 18th, 2005
    Posts
    5,482
    You should set your limit in your select statement.

    $result = @mysql_query("SELECT * FROM yourtable WHERE field = 'whatever' limit 0,25");

  3. #3
    ABW Ambassador
    Join Date
    January 18th, 2005
    Location
    ÄúsTrálíĺ
    Posts
    1,372
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by M.McNabb:
    You should set your limit in your select statement.

    $result = @mysql_query("SELECT * FROM yourtable WHERE field = 'whatever' limit 0,25"); <HR></BLOCKQUOTE>

    Then,

    while ($line = mysql_fetch_array($result)) {
    echo "&lt;strong&gt;$result['department'] &lt;/strong&gt; ---&gt; $result['brandname']&lt;br&gt;\n";
    }

  4. #4
    Full Member
    Join Date
    January 18th, 2005
    Posts
    230
    Then to get the next 25 from your db:

    $result = @mysql_query("SELECT * FROM yourtable WHERE field = 'whatever' limit 25,25");

    and the next 25 would be...

    $result = @mysql_query("SELECT * FROM yourtable WHERE field = 'whatever' limit 50,25");

    etc.

  5. #5
    Full Member dak142's Avatar
    Join Date
    January 18th, 2005
    Posts
    386
    You Guys are the best resource for information! I also posted this same question a WWW and NO ONE has responded. Thank you to all of you! I have one more test for your knowledge! I am also looking for a way to rank links on my site, kind of a "most popular" or a way to dispaly the top couple of links getting the highest click through. Is there an easy way to go about it, or is there a script out there somewhere to serve the purpose. I think there may be one, but I can't seem to ask the search engines the right question, any suggestions?

  6. #6
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by Dak142:
    I am also looking for a way to rank links on my site, kind of a "most popular" or a way to dispaly the top couple of links getting the highest click through. <HR></BLOCKQUOTE>
    Are you currently keeping tracking records in your db?

    If so, it's just a matter of grabbing the top x links off the list:

    SELECT * FROM url_list ORDER BY clicks DESC LIMIT 0,10

    If you don't already grab your own clickthrough data, do it by using a redirection script.
    “An adventure is an inconvenience rightly considered. An inconvenience is an adventure wrongly considered.” - G.K. Chesterton

  7. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. PHP and MySQL Knowledge
    By scm21st in forum Midnight Cafe'
    Replies: 5
    Last Post: August 5th, 2007, 10:30 PM
  2. looking for php/mysql work
    By spiderninja in forum Midnight Cafe'
    Replies: 0
    Last Post: January 31st, 2007, 11:12 PM
  3. Grouping with PHP and MySQL
    By Doug247 in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: March 24th, 2005, 10:07 AM
  4. PHP & mySQL but....
    By perfectG in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: November 6th, 2002, 06:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •