SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict animgirl's Avatar
    Join Date
    Oct 2003
    Location
    Land of the free, home of the brave
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question A query to hide all past events?

    Hello,

    I know a little about PHP/MySQL.
    I have a MySQL database and admin panel setup where I can go in and add event dates for this website.

    I want to take things a step further. I want the past event dates to automatically "hide" themselves from being seen on the website, yet not get deleted from the database. A friend of mine suggested adding a new field to my current database to make this happen somehow.

    I have attached a screenshot of my database. Do you have any ideas?

    I appreciate your help,
    Attached Images Attached Images
    Elise Henley

  2. #2
    SitePoint Guru asterix's Avatar
    Join Date
    Jun 2003
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your thumbnail is interesting, but not useful.
    We need to see the table definition, otherwise known as DDL.

    I have an awful feeling that the data in your [date] field is not of the datatype "DateTime", but is actually a varchar or something.

    Also, it is never a good idea to have columns named things like "date" and "time". They could easily be (although luckily not for mysql) reserved words.

    Quote:
    http://dev.mysql.com/doc/mysql/en/Reserved_words.html
    MySQL allows some keywords to be used as unquoted identifiers because many people have already used them. Examples are those in the following list:

    • ACTION
    • BIT
    • DATE
    • ENUM
    • NO
    • TEXT
    • TIME
    • TIMESTAMP

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you could add a column to the table to indicate that a particular entry was expired or not

    and then when you are returning data from the database to show on the web site, the query would have

    ... where expired = 0

    you could, but it wouldn't be a good idea

    you'd have to constantly (e.g. on a daily basis) go through the table and flag any rows that had lapsed into expired status

    instead, it is more common simply to omit showing them based on the current date

    ... where event_date >= current_date

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •