I am rebuilding a website with a sign-up form. There only 20 beds in a cabin available. In the signup form I want to show how many beds are available, counting down from 20 and stop showing the option when all beds are reserved. In mysql I used to do it with
<?php
if ("".(20 - $countzwerf->TotalRows) ."" != "0") { // Show If
?> Ik wil een bedje in een zwervershut (+€ 10,00, nog <?php echo (20 - $countzwerf->TotalRows) ?> beschikbaar)<?php
They are stored in a table, and then counted like this:
<?php
$countzwerversbed = new WA_MySQLi_RS("countzwerversbed",$baksorder_i,1);
$countzwerversbed->setQuery("SELECT * FROM deelnemers WHERE overnachting = 'zwerversbed'");
$countzwerversbed->execute();?>
Let me try to explain. When one books they choose how/where they will sleep. I option is called “zwerversbed”. When selected, tekst “zwerversbed” will be inserted in the field “overnachten”. I used to count the total records where “zwerversbed” was added (record count). I have a max numer of 20 “zwerversbedden”. So everytime someone adds “zwerversbed” to sleep, it is substracted from the number 20 (max. beds). When record count for “zwerversbed” <1 then the option “zwerversbed” will not be shown anymore.
I hope this makes any sense
That is why asked you - are you storing somewhere which beds are reserved like in a column in the table or in another table? How do you mark the reserved ones?
The make a selection in the form for “zwervershut”. Then “zwervershut” is saved in the field “overnachting” in the dbasetabel. The count counts all mentions of “zwervershut” in the records and then comes up with a sum. That sum needs to be substracted from the number 20. Which will result in the total number of beds available. If the total number of beds available is 0, the “formselect” should be hidden, so only the alternatives will be available. http://testworks2.nl/inschrijven.php under “overnachting”. I changed that part to English for better understanding.
If i understand you right, you just need a query, which is filtered by the word "zwerversbed" - filter the overnachting field.
Then on the page this query will show the reserved beds number using the count formatter.
Almost. I have that part working. I need to substract the number of reserved beds (now 1) from the available beds (20) to show the number of actual available beds.