hi, I'm trying to setup a webform with select components so a user will register to an event.
I don't want to use the signup module because of 2 main reasons: 1. I can't limit the # of Events a user can register at the same time and 2. using hidden components I can show the user's profile in the same table without coding...
Bassically what I need is a php script (I guess) that does the following:
Count the available sits on each of the select options to prevent a user registers to an Event that is Full.
for the first option the query will look like this: select count('data') from webform_submitted_data where data='Event 1'. If the query result is 150 and the available sits are 150 "Event 1" option will be disabled OR a user will get an Error Message saying "Event is Full".
This will be for each of the different options, all of them have different available sits.
I guess I can do this in the Additional Validation or Additional Processing Settings but the problem is my php skills, I've been reading lots of docs but nothing.
thanks in advance. any help will be appreciated.
Luis
Comments
Comment #1
lelizondo commentedI've been trying to solve this but I it's not working. I'm using this code after 1 day of research
I get a WSOD with a 0 and no error is showing and the form saves the data in the database anyway.
What I'm trying to do is setting up a limit to an event, (using webform and checkbox component), to prevent a user from selecting an event with no seats available. I'm using the query to know how many users registered to the event selected in $mydata and if the limit has been reached the user gets an error message and he/she has to select another option.
What am I doing wrong? Any help?
Thanks
Luis
Comment #2
lelizondo commentedHere's the solution I've found:
I'll try to explain myself, as I didn't have php experience.
First, I had to validate the submitted value to know how many times this value was submitted before, to do so, I used the next query:
The variable $mydataevent it's equal to the submitted value on the webform. But I had a problem with this, it seems that for some reason, $form_values['submitted_tree']['event']; was formatting the name of my event from "Event Name" to "event_name". I didn't know why, so I had to format it back to "Event Name".
To do it, I used switch ($mydataevent) and defined every case and specified a new variable called $maxlimit, which is the Limit of the Selected Event.
After this I just wrote an if to know if my query was greater than the maxlimit.
Here's the code.
Hope it helps somebody else.
Luis
Comment #3
lelizondo commentedjust to change the status
Comment #4
quicksketchThanks for sharing lelizondob!
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.