SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict madproject.com's Avatar
    Join Date
    Jan 2003
    Location
    Ottawa, Canada
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL if-statement

    I need to have an if statement in my SELECT that will only select items that their datestamp is the same as the current day or later.

    PHP Code:
    $query "SELECT id, type, user, ad, img FROM madevents WHERE category=$category LIMIT 0, 10"
    Somewhere in there I must have date control. I haven't made a datestamp field yet. But I will.

    So basicly I will replace the LIMIT 0, 10 for the if statement.
    Free Picture and Video Hosting
    [http://photocabin.com][http://madproject.com]

  2. #2
    SitePoint Wizard Chris82's Avatar
    Join Date
    Mar 2002
    Location
    Osnabrück
    Posts
    1,003
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try:

    Code:
    SELECT id, type, user, ad, img 
    FROM madevents 
    WHERE category=$category
    AND datecolumn >= Now();
    It works only with the mysql date / time column formats.

  3. #3
    SitePoint Addict madproject.com's Avatar
    Join Date
    Jan 2003
    Location
    Ottawa, Canada
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll give it a shot
    Free Picture and Video Hosting
    [http://photocabin.com][http://madproject.com]


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
  •