Jump to content

[SOLVED] Sorting/Dates kinda question :$


stoneymedia

Recommended Posts

Hello PHP Freaks!

 

Im a brand-new noobie, so please forgive me if this is in the wrong place, or not helpful at all! Basically, im stumped with a PHP/MYSQL issue im having..

 

I have a table in my database, and a php page which displays data from the table.. I need to only display particular content, and I need it sorted by date, let me try and explain where I am.

 

SELECT * FROM event_ WHERE field_1='F501 BF1' ORDER BY field_6

 

^^ is my current Query for MySQL, if I type that into the SQL Query box within PHPmyAdmin, I get back

 

http://www.formula500.org/nextrace/f501schedule.php which seems to think that June comes before July..

 

Can anyone explain if I've gone wrong... where and how? Im sorry, ive not done a great job explaining it here.. it sounded easier in my head..

 

I basically need the data in field_1 to display all the entries which are "F501 BF1" and order them by field_6..  ???

Link to comment
Share on other sites

I'd agree with that last post. They appear to be sorted alphabetically so I'm guessing the 'date' is stored in a varchar field.  No,no,no. Store dates in a date field and use the standard, sortable, ISO form yyyy-mm-dd.  You will be able to 'operate' on dates in that format and you can display them in your choice of date style.

Link to comment
Share on other sites

I'd agree with that last post. They appear to be sorted alphabetically so I'm guessing the 'date' is stored in a varchar field.  No,no,no. Store dates in a date field and use the standard, sortable, ISO form yyyy-mm-dd.  You will be able to 'operate' on dates in that format and you can display them in your choice of date style.

 

You guys are absolute stars. Thank you.

 

I worked through the responses in this thread, and was just starting to put my reply together, clicked submit and forums told me another post had been made, so I read it through, seen about the date field and using the yyyy-mm-dd format, so I tried this, and it works lovely.

 

Thank you again. :)

Link to comment
Share on other sites

Afternoon guys :),

 

I have a second request/question.. I have done what I wish to do for the above, so thats put to bed with, however, I now need a page to display data from the same database slightly differently.

 

I wish to pull the data from the database automaticly based on the actual date.

 

For example:

 

If the actual date was 6th July 2008, and I wanted to show events happening in the week between 6th July and 12th July, would there be a function that could pull events that fall between those dates from the database, and display them in next event order?

 

I realise this could get a little complex, so its not essential, as in, I could do this manually by hand, but if it was something which automaticly updated, that would be very cool :)

 

Thanks again for any advice.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.