Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 1st, 2003, 06:06 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Fetching records in a cyclic order

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


Reply With Quote
  #2  
Old June 1st, 2003, 06:28 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Fetching records in a cyclic order

try using the LIMIT statement in your SELECT query.

you can find an explanation of LIMIT here:

http://www.scriptygoddess.com/archives/003313.php

Scroll down the page a little and you will find the explaination.

Reply With Quote
  #3  
Old June 1st, 2003, 07:22 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Fetching records in a cyclic order

Blindeddie,
Thats what i was not looking for.well, i can just only limit the records.My question was something different.40 records today and the next 40 tomorrow and it continues like wise.
Thanks anyways.

Reply With Quote
  #4  
Old June 1st, 2003, 07:44 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Fetching records in a cyclic order

on day 1 the query would be

select * from mytable limit 0, 40

on day 2...

select * from mytable limit 40,40

on day 3

select * from my table limit 80, 20..

based on your post, this is what you want to do is it not?

the first number in the limit statement determines what record the displayed records starts at.


Reply With Quote
  #5  
Old June 1st, 2003, 08:03 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Fetching records in a cyclic order

Blindeddie,
Exactly!you got it.Thats what i want to do actually.I dont think thats gonna work with my script, cuz before i display the records i limit the no.of reocrds to display on the page is 10.Thats how i did with the pagination.I've no clue how shld i proceed further.

Thanks for your time

Reply With Quote
  #6  
Old June 1st, 2003, 09:00 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Fetching records in a cyclic order

I see what you are saying. Not quite sure how to handle that unless you can add an indicator to the table that flags groups of 40 records and then on a specific day select the records you want for example:
(this will only work if your table is static)
add a column to your table called 'day_to_display'. Use a number to indicate that the record should be displayed on a specific day. Day1 = 1, Day2=2 etc... then assign those numbers to banks of 40 records in the table. Then in your select query you could specify which group you wanted to display. since ther will only be 40 records selected, yuo can use the limit statement to do the paging. Like I said, this will only work if the table is static.

Reply With Quote
  #7  
Old June 5th, 2003, 09:29 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: Fetching records in a cyclic order

Blindeddie,

I found the solution for this one.First, i got the weekday with this piece of code
php Code:
Original - php Code
  1.  
  2. $today = getdate();
  3. $day = $today['weekday'];

and then i used switch statement to get the records based on the day, something like:
[highlight=php]
switch($day)
{
case "Monday":
$query="select * from mytable limit 40";
break;
case "Tuesday":
$query="select * from mytable limit 40,40";
break;
and so on...
}

so simple aint it??
cheers

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Fetching records in a cyclic order


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway