Adding searchable opening times on e-directory

Posted on 2010-08-20
Last Modified: 2013-12-13
Hope all is well.
I have another e-directory problem.

I need to add an option for the client to add their opening times for each day, from their account, which can be searched by the frontend user.

So I'm guessing the best way to go about it is in the backend have the 7 days listed with a list of 3 times where the user can put in opeing times.

So like:
 Monday:    8:00 - 12:00
                 13:00 - 17:00
                 18:00 - 22:00

I think the best optionfor that would be drop down menus for each time.

Then on the front end have drop down menus for each option so drop down for days then open and close.

I am not sure how to go about doing this.
I'm open to suggestions about how to lay it out and work.

I'm not sure which files I need to edit or how to get it to write to the table to make it searchable from the front end.

I went into the phpadmin and I've attached the exports from the database tables.

This is a link to the front of the site .

Any help or suggestions would be great.

Thanks in advance.

Question by:Kevin2010
  • 5
  • 5
LVL 110

Expert Comment

by:Ray Paseur
ID: 33483315
For starters, I can offer some general guidance on how to handle DATETIME information in PHP and data bases.

Can you be a bit more specific about the question?  Thanks, ~Ray

Author Comment

ID: 33483368
Thanksfor that. I'll have a read up on that.

Sorry about that what it is I'm not sure how to add the options for the advertiser/clients to enter the opening times for specific days. Then from the front end allow the user to search through the database after selecting specific times and days.

LVL 110

Expert Comment

by:Ray Paseur
ID: 33484078
Generally, business opening and closing times are set according to the days of the week.

To find if a business is open "now" you would query the data base for all the Friday records and look to see if "now" is between any of the opening and closing times.

You could use Javascript and AJAX and make this complicated with dropdown select lists, but a simpler design might be to list the days of the week and allow the client to type in the opening and closing times.  You can use strtotime() to evaluate the client input.  I would think that three sets of opening and closing times would be enough.

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Author Comment

ID: 33484981
Thanks for your reply.

That would be for the backend yeah?
So strtotime() would store it?

I was considering the dropdown for the frontend of the site just for the day. I thought that might be easier to check the database with. Then have two fields for the user to type in two times which would search the database for businesses open during that period.
LVL 110

Expert Comment

by:Ray Paseur
ID: 33485046
Strtotime() converts human-readable DATETIME strings into UNIX timestamps.  If strtotime fails, the string is not usable as a DATETIME value.

You use strtotime() and date() together to manipulate DATETIME strings.

So if I wanted to tell you a time, I could use something like this: 8:30 a.m. or 0830 or 3:00pm or 15:00:00.  These would all work.  If I said, "one hour ago" it might work.  there is great flexibility.

Can you tell me a little more about the search you want to offer the clients?  

Author Comment

ID: 33485275
Oh ok thanks

I want to allow users the option to search for a specific business at a certain time of a specific day.

So say I want to go to a resturant tonight at 9pm. I'd go on there type resturant then area then select Friday  then type 9:00pm - 10:00pm

So the results would come back with all the resturants open between 9:00pm and 10:00pm on Fridays near/in the area I want.
LVL 110

Expert Comment

by:Ray Paseur
ID: 33485379
Got it - that makes sense.  I would just use text fields for the times with a default value of "now".  Probably a SELECT dropdown for the business type.  Probably a text field for the day, with a default value of "now".  IIRC "now now" works with strtotime.  You can test on my web site here:

Author Comment

ID: 33485598
Thanks for this.
I'll have a go at trying to implement that.
Currently on the frontend it just as a box for you to type a keyword so you recommend a select drop down instead.

If I do that in the backend I'd have to give the same options for the advertiser(the person who is adding their business to the directory) to select their business type?

How would I go about adding that as well as their opening time to get them added to the database.

LVL 110

Accepted Solution

Ray Paseur earned 500 total points
ID: 33485850
Based on that question, I think you might want to hire a developer.  What you're describing is not "hard" or anything - it's just a lot of application design and data base normalization work.  If you're relatively new to PHP and MySQL, this book might be helpful.

Best of luck with it, ~Ray

Author Closing Comment

ID: 33486347
Thanks for all your advice on this and quick responses.
I really appreciate your advice and will look into getting the book you reccomended and hiring a developer.


Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question