Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Feb 2003
    Posts
    15
    Member #
    609
    Hello everybody,

    I have 100 records in a table and I would like to show 1 to 40 today and 41 to 80 tomorrow and 81 to 20 the next day.so, something like in cyclic process.

    How should i write my sql query??

    Many thanks

  2.  

  3. #2
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Not quite sure exactly what you mean... but one possibility is using some simple datemath. Use php's date() (www.php.net/date) function to get the day of the week as an interger, then simply multiply it.

    $bottomlimit = (getdayofweek)*40 + 1;
    $toplimit = $bottomlimit + 39;
    $sql = "SELECT col_name FROM table_name WHERE 1 LIMIT $bottomlimit, $toplimit";

    etc. Keep in mind that's merely the method it would take quite a bit of fine tuning and a bit of problem solving to figure out exactly what you need and how to do it.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  4. #3
    Junior Member
    Join Date
    Feb 2003
    Posts
    15
    Member #
    609
    Brak,
    Now, i have a page where i show 10 records in a page and i provided previous/next links to view other records.
    As of now there are 100 records in the table.I just only want to show the first 40 today.That shld be possible with the sql limit.I dont want to end upto here- like to show 41 to 80 the next day and this has to be continued in the cyclic order.

    I know this is really a complicated one, but like to make a start.

    With the code which I've now, i tried to use sql limit in my query and it gives me the error message"Does'nt execute it"!Is that because i used $limit = 10(no.of rows to display) at the beginnning of my query.
    Does this limit and the limit in the query is colliding???

    Thanks


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:42 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com