CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 How to restrict insert per group of rows in same table

Print topic Send  topic

Author Message
Sasham

Posts: 2
Posted: 02/08/2009, 9:10 AM

I have the following table:
wms_results[rec_id, lab_id, sample, SPC_A, SPC_B, Coliformb_A, Coliformb_B, Coliformf_A, Coliformf_B].
The sample field can be of value A & B & C & D. (Each lab can only enter 4 samples)

If lab ABC01 enters results for all 4 samples, how do I stop inserts of duplicate values of sample.
Edit and delate are allowed at any time.
If using the property 'unique' on field sample, it prevents other labs from entering these samples.

Using php4 & mysql 3.23

I am new to CC4 and struggle with the custom code.
View profile  Send private message
damian

Posts: 838
Posted: 02/08/2009, 6:55 PM

wouldnt you put unique on the lab_id if they can only enter once?

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
damian

Posts: 838
Posted: 02/08/2009, 6:59 PM

or in page before show do a check on the table for all records where lab_id=CCGetUserID() (assuming this is your case! - otherwise use similar expression) - if the result = 1 hide the add/edit grid and display a message - "thankyou - we have already received your results for this program"

_________________
if you found this post useful take the time to help someone else.... :)
View profile  Send private message
Sasham

Posts: 2
Posted: 02/08/2009, 9:41 PM

Thanks Damian,

Each lab can submit 4 samples ie A,B,C,D then no more. Making lab_id unique will only allow each lab to submit one sample.
I am considering splitting each sample into its own table which will make the coding simpler, but will complicate later analysis of the data where I need it all in one table.

The labs also need to be able to go in and edit the results after they have submitted the 4 samples, so I cannot hide the edit function, only prevent adding more duplicate samples.

Let me know if there is an easier way that I am missing here!
View profile  Send private message

Add new topic Subscribe to topic   


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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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