Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to order results?
Old 05-23-2005, 04:18 PM How to order results?
Average Talker

Posts: 15
Trades: 0
In my database I have a table, and each record has a date field. How can I get the results listed in order from today's date on?

Instead of ordering the results from January 1st to December 31st, I want them ordered from Today's date (May 23rd) to December 31st and then on to May 22nd of the next year.

Each time the database is queried the results need to be ordered from the current day on (not just from a set date).

Possible?
jacannon2 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-23-2005, 05:11 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Trades: 0
Try this.
PHP Code:
//Get todays date
$today date("Y-m-d");

//set the end date
$enddate "2006-05-22";

//set your query to this

$query "SELECT * FROM table_name WHERE date>='$today' AND date<='$enddate' ORDER BY date ASC"
This should work provided the MySQL column is defined as a DATE column

Regards
Ian
__________________
Found this useful? - HIT MY TALKUPATION!


Please login or register to view this content. Registration is FREE
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 04:35 PM
Average Talker

Posts: 15
Trades: 0
I did define a date column, but these aren't from the years 2005 and 2006. They are actually birthdays with dates from the 60's, 70's, etc.

I tried what you gave me, but I guess I'm not understanding something.

Here's some info:

TABLE NAME: birthdays

FIELDS: FirstName, MiddleName, LastName, month, day, year, date

The date is a "date" type field.

I put month, day and year just in case I needed those fields. Their number data types.

I'd like to display this:
------------------------------
Bob Jones turns 20
on May 31

Norah Williams turns 42
on June 6

etc...
------------------------------

With that, how should I code this thing? I'm fairly new at working with databases, so forgive me if I don't catch on fast enough.
jacannon2 is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 06:52 PM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Trades: 0
Hi,

Okay, I think I have a better understanding of this now and it is a little more complex than I first thought. I will try to look at this over the next day or so and get back to you.

I take it you would like to print out for the next 12 months from the date you made the query, ie if you query database on 24 May 2005, you want all birthdays up to and including the 23 May 2006. Is this correct?

Regards
Ian
__________________
Found this useful? - HIT MY TALKUPATION!


Please login or register to view this content. Registration is FREE
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 05-24-2005, 11:28 PM
Average Talker

Posts: 15
Trades: 0
Yes, that's correct.

It's basically a list of upcoming birthdays that will update every day. I only want the top five to be displayed, but it would be nice to have the ability to change how many birthdays are displayed.

I've been able to display the list of birthdays in order from the beginning of the year to the end of the year, but that's not what I'm wanting. I want it to display from the current day forward into the next year. Nothing else special. No calendar or anything. Just a list.
jacannon2 is offline
Reply With Quote
View Public Profile
 
Old 05-25-2005, 08:10 AM
celticbrue's Avatar
Extreme Talker

Posts: 175
Location: Wiltshire, England
Trades: 0
Hi,

I have had another look at this and it's got me beat for now. I am sure it can be done using some array functions, but I am under the cosh on some paid projects at the moment and I have to devote my time to that.

When I get a chance I will come back to it, because I don't like being beaten and it would be good to know how to do this.

Sorry mate, but I have to pay the bills.

Any Array gurus out there?
__________________
Found this useful? - HIT MY TALKUPATION!


Please login or register to view this content. Registration is FREE
celticbrue is offline
Reply With Quote
View Public Profile
 
Old 05-25-2005, 09:10 AM
Average Talker

Posts: 15
Trades: 0
Thanks anyway.
jacannon2 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to order results?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.80860 seconds with 12 queries