expiring products (PHP & MySQL)

Discussion in 'Web Design and Development' started by vendettabass, May 16, 2008.

  1. vendettabass macrumors 6502a

    vendettabass

    Joined:
    Jul 8, 2006
    Location:
    Seoul, South Korea
    #1
    I'd say I'm a newbie to PHP and MySQL, and am looking for a solution to this problem!

    I have to create an auction site for my coursework, and I'm trying to make auctions that expire.. well.. expire. I have 'Expires' and 'Starts' stored in my SQL table, obviously.

    I want to make sure on the home page, only auctions that have not expired are displayed - as you can see, this, at the moment is not the case.

    To add the 'Expires' value to a product, I used this MySQL code:

    and here is my homepage script:

    any help to how to tackle this would be appreciated, I'm having a real hard time!
     
  2. chrish macrumors newbie

    Joined:
    Jun 12, 2007
    Location:
    London, UK
    #2
    What's the select statement you are using for the actions on the page?

    I think you need to add something like ...

    select *
    from smith_auctions
    where Expires > now()
     
  3. SrWebDeveloper macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #3
    The method I like is to add two MySQL datetime fields such as notLiveBefore and notLiveAfter both of which determine a time window the content is active, otherwise its expired. Plus this allows users to delay the start of auctions if they wish as well as determine when they stop.

    Exmple: The query would include as part of the select statement using the if command, returned as an alias named 'Status'...

    Or you could use a variation of it in your where clause if you wish to exclude active or expired content in your result set. Remember the if command in MySQL determines if(condition,true,false) in case you're not familiar when used in the select part.

    Get the idea?

    -jim
     
  4. vendettabass thread starter macrumors 6502a

    vendettabass

    Joined:
    Jul 8, 2006
    Location:
    Seoul, South Korea

Share This Page