Web Design Forum: How to store opening times - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to store opening times Rate Topic: -----

#1 User is offline   pilgrim_fgau 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 99
  • Joined: 17-September 10
  • Reputation: 1

Posted 23 January 2012 - 03:17 PM

Would anybody have any recommendations on a schema for storing opening times of a gym in a database. I want to be able then search different gyms for opening times from e.g 9am onwards and also search for closing times, e.g stays open until 10pm. Baring in mind that certain days will have different opening times.

Would I have to store this as fields like:

Mon_Open
Mon_Close
Tues_Open
etc
etc

Does this sound right? Im quite new to php and SQL so just trying to get my head around a few things for a project I have coming up.

Thanks in advance
0

#2 User is offline   websiteprodigy 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 15
  • Joined: 16-January 12
  • Reputation: 1
  • Gender:Male
  • Location:Nottingham
  • Experience:Advanced
  • Area of Expertise:Web Developer

Posted 23 January 2012 - 05:34 PM

I think you're on the right track with this.

Your first column would need to be the Gym_ID and then integer fields for the opening and closing times for each day Mon_Open, Mon_close ... etc.

Then you could search the opening times with something like:
SELECT * FROM `opening_times` WHERE `Mon_close` > 7 ORDER BY `Mon_close` DESC


Ideally you would JOIN with your Gym table to get the gym name etc. but one step at a time
0

#3 User is offline   pilgrim_fgau 

  • Forum Newcomer
  • Pip
  • Group: Members
  • Posts: 99
  • Joined: 17-September 10
  • Reputation: 1

Posted 23 January 2012 - 05:57 PM

View Postwebsiteprodigy, on 23 January 2012 - 05:34 PM, said:

I think you're on the right track with this.

Your first column would need to be the Gym_ID and then integer fields for the opening and closing times for each day Mon_Open, Mon_close ... etc.

Then you could search the opening times with something like:
SELECT * FROM `opening_times` WHERE `Mon_close` > 7 ORDER BY `Mon_close` DESC


Ideally you would JOIN with your Gym table to get the gym name etc. but one step at a time


thanks dude, at least im pointing in the right direction :)
0

#4 User is offline   Jay Gilford 

  • Web Guru
  • PipPipPipPipPip
  • Group: Members
  • Posts: 1,105
  • Joined: 11-October 09
  • Reputation: 185
  • Gender:Male
  • Experience:Web Guru
  • Area of Expertise:Web Developer

Posted 23 January 2012 - 06:21 PM

personally I would have the day as a separate field, so it's not mandatory to search for the day, with the following fields

record_id - Primary key
gym_id - A key relating to gym info in a gym table
opening_time
closing_time
day


That way you could search and pull all days that the gym is open at a certain time say
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users