ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

PHP/HTML help.



Typhoon

Gangsta
ClioSport Moderator
Hi guys,

Writing a new website for a friend who owns a fitness class company.

While I build some kind of RSVP/Diary system, we've agreed for now we can just have a form people fill in and it'll email him the completed form.

For example;

Name:
Email:
Date Selected:

---
The issue:

There are 30 spaces per class.

Where they select the date, there will be a list of preset dates that my friend can do, for example:

Tuesday 12th September
Thursday 14th September
Tuesday 19th September
(These are all made up, not even sure they're actual days, dates)

I want it so that each date can only be selected a maximum of 30 times and for it to be shown next to each date, again, example:

Tuesday 12th September (11 places remaining)
Thursday 14th September (22 places remaining)
Tuesday 19th September (8 places remaining)

Obviously, once it hits '0 places remaining' then this option becomes grey'd out from the dropdown box.

Any one with an idea on the easiest way to incorporate this in to a contact form?

Cheers
 

Nik

ClioSport Admin
  Clio Trophy #355
I'd think you'd be best to have a simple mySQL database behind it.

Could be a simple single table with 3 columns (name, email, dateselected) to store the responses.

Have a query in the php for the date drop down that would count responses where dateselected = x and then an if statement to echo the <option> html to add that dates option to the dropdown with number left (30-the result of count query) if count is <=30 else echo the same <option> html but with the disabled option added (i.e. <option value="volvo" disabled>Volvo</option>) which will grey it out as that date is now full.

You can add a bit of code to email at the end of this or create a page that show a list of all attendees instead of messing with email.
 

Typhoon

Gangsta
ClioSport Moderator
I'd think you'd be best to have a simple mySQL database behind it.

Could be a simple single table with 3 columns (name, email, dateselected) to store the responses.

Have a query in the php for the date drop down that would count responses where dateselected = x and then an if statement to echo the <option> html to add that dates option to the dropdown with number left (30-the result of count query) if count is <=30 else echo the same <option> html but with the disabled option added (i.e. <option value="volvo" disabled>Volvo</option>) which will grey it out as that date is now full.
Cheers broski. Had a feeling it was going to entail databasing!
 

Nik

ClioSport Admin
  Clio Trophy #355
You could store the numbers in a text or xml file instead I guess if its a simple count, and then just use a basic contact / reply form php to email the info but modify it as above to control the date field based on the numbers stored in the file.

file_put_contents('filename.txt', $count);

echo file_get_contents("filename.txt");

you'd have to read back the value on page load and then +1 as necessary every time the form was submitted.
 

Sam

North East
ClioSport Area Rep
Does he have a server to host the site on? Something like this would be pretty easy to write in fairness.
 


Top