4 Replies - 6163 Views - Last Post: 13 June 2011 - 12:25 PM Rate Topic: -----

#1 drewpark88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-February 10

Logical Solution for DB query

Posted 13 June 2011 - 09:20 AM

Hey Guys,

I have an "events" table in my DB and a "default_events" table also. Every day I display one event. I check to see if any rows in the "events" table match todays date and then display that event, if no events match by date, I check the "default_events" table by week day (like Wednesday).

I can display events and default events fine based on date or day, but I have a "limited_spots" field in the default_events table used for allowing only so many people to rsvp for that default event. So lets say a default event that happens every Monday is supposed to show 50 spots, then it is down to 1 spot left by the end of the day. Next Monday I need the spots to be back up to 50 and to remove the event participants from the guest list.

How should this be done? Any help would be greatly appreciated, thanks!

- Drew

Is This A Good Question/Topic? 0
  • +

Replies To: Logical Solution for DB query

#2 Duckington  Icon User is offline

  • D.I.C Addict

Reputation: 170
  • View blog
  • Posts: 608
  • Joined: 12-October 09

Re: Logical Solution for DB query

Posted 13 June 2011 - 09:25 AM

Have a google for "cron jobs". I think that's what you are after from the sound of it.
Was This Post Helpful? 1
  • +
  • -

#3 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: Logical Solution for DB query

Posted 13 June 2011 - 09:34 AM

You'll have to add a where clause to your query.
WHERE `limited_spots` > 0
.

To run a command on your DB you'll schedule an event. ushastry.blogspot.com/2009/09/mysql-event-scheduler-or-scheduled.html
Was This Post Helpful? 1
  • +
  • -

#4 drewpark88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-February 10

Re: Logical Solution for DB query

Posted 13 June 2011 - 09:34 AM

Well, I was considering running a cron job but was not sure if that was the best way.

View PostDuckington, on 13 June 2011 - 09:25 AM, said:

Have a google for "cron jobs". I think that's what you are after from the sound of it.

Was This Post Helpful? 0
  • +
  • -

#5 drewpark88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 08-February 10

Re: Logical Solution for DB query

Posted 13 June 2011 - 12:25 PM

Nevermind, figured out a much easier solution. Thanks though : )
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1