CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Limiting number of records with same value

Print topic Send  topic

Author Message
crispy63
Posted: 10/22/2002, 8:45 AM

I have a volunteer signup site created with cc and php 4.0 (with templates). On it, members sign up for work shifts. There are 3 work shifts per day, 5 workers per shift. I am trying to limit the number of "workers per shift" that members can sign up for on a given shift (i.e. - only 5 people can sign up for any one shift, if #6 tries to sign up, they cant).
My table includes shift_date, shift_time, member, and shift_id fields. If anyone has any ideas, starting points, or solutions that could help me limit the number of records per shift it would be much appreciated.
Nicole
Posted: 10/24/2002, 6:33 AM

Hello,
As I understand the user selects the shift to sign up for, i.e. the shift_id is stored in the users table. To be able to limit the number of users per day you should store the date of sign as well. Then in the Before Insert event count the number of users who sign up for the shift using dlookup() function. E.g.:
$number = dlookup("users_table", "count(*)", "shift_id= " . $fldshift_id, “ and date_field= ". ToSQL(date("Y-m-d"), Date))

if $number is greater then given value you can add error message or just redirect user to select another shift.
crispy63
Posted: 10/27/2002, 6:50 AM

Thank you very much! This is exactly the solution I was looking for -- I owe you one!

Crispy

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.