T
|
thesofa 10/19/2008 |
I have the following Event for 4.2 in Events/Before Record Added // Parameters: // $values - Array object. // Each field on the Add form is represented as a 'Field name'-'Field value' pair //** Limit Number of Records to One **** global $conn,$strTableName; $str = "select count(*) from _Table_Items where Product_Number='".$values["Product_Number"]."' and User_ID='".$values["User_ID"]."'"; $rs = db_query($str,$conn); $data = db_fetch_numarray($rs); if ($data[0]) // if record exists do something $message = "<font color=red>You have reached your limit for this Item.</font>"; else // if dont exist do something else return true; // return true if you like to proceed with adding new record // return false otherwise this Event works fine for limiting to 1 Record per User(User_ID) in "Items" (table name) where they have already added a record for a Specific Item(Product_Number). which is what I want. now how do I change it from a limit of 1, to any other number say 3 or 5? I assume it's in " if($data[0]) " and changing the 0 to another number doesn't work.
global $conn,$strTableName; |
E
|
erago author 10/19/2008 |
try this global $conn,$strTableName;
|
E
|
erago author 10/19/2008 |
|
T
|
thesofa 10/19/2008 |
Thank you that did the trick. what would be the proper code if I was looking for NULL in a field value such as " and Field_B='".$values["Field_B"]."' " have tried is_null and a few others, with no luck, anyone have any ideas how to specify that I only want to consider records with NULL in Field_B ?
|
E
|
erago author 10/20/2008 |
Thank you, |