Jump to content

Date Trouble


Granny Annie

Recommended Posts

The script below references a data base with shows from 2008 and 2009. It selects the next four sequential dates to list, but ignores the year. So I have shows from 2008 included.  Suggestion?

 

<?php

  $cur = date("m/d/y");

mysql_select_db("shows", $con);

 

$s = mysql_query("SELECT * FROM live WHERE date >= '$cur' ORDER BY date LIMIT 0, 4");

 

        while($r = mysql_fetch_array($s))

        {

        echo $r['date'] . " <br> " . $r['place'] . " <br> " . $r['time'];

        echo "<br />";

echo "<br />";

 

Link to comment
Share on other sites

"m/d/y"

 

Is your date field in that same format? If so, you cannot do any comparisons or sorting using that format because the fields that make it up are not ordered from MSD (most significant digit - Y) to LSD (least significant digit - d). If you want to do date comparisons or ordering by dates the format must be YYYY-MM-DD (with leading zeros), which is why the DATE data type exists.

Link to comment
Share on other sites

I'm way new at this and have taken over a band website after the designer skipped town. I understand what you are saying, but where do I find the date field?  Is this where I enter the show dates to begin with?  I have a pull down list for Month/Day/Year. I want shows to list with the month first, then day, then year.  I'll try to find the code and copy it into a message.

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.