This topic is locked
[SOLVED]

 Prevent Duplicates with Multi records

5/10/2017 3:11:16 PM
PHPRunner General questions
M
maaroufkamel author

Thanks in Advance to all PHPrunner Team
i would like to know how to prevent Duplicates in multi fields validation
i a have a table named Doc_Management and the records [Date] [Registeration_No] [Trans_No]
i want to prevent to add the same ([Registeration_No] and [Trans_No]) in the same year but it cans in anther years

romaldus 5/10/2017



Thanks in Advance to all PHPrunner Team
i would like to know how to prevent Duplicates in multi fields validation
i a have a table named Doc_Management and the records [Date] [Registeration_No] [Trans_No]
i want to prevent to add the same ([Registeration_No] and [Trans_No]) in the same year but it cans in anther years


In your database, create unique index

M
maaroufkamel author 5/11/2017



In your database, create unique index


i am trying to use like this code
global $conn;

$sql = "SELECT * FROM dbo.Doc_Management WHERE Registeration_No ='".$values["Registeration_No"]."' AND Trans_No ='".$values["Trans_No"]."' ";

$rsExists = db_query($sql, $conn);

$data=db_fetch_array($rsExists);
if($data)

{

$message = "Registeration_No & Trans_No Already Exists in this Year".$values["Registeration_No"]." already exists in database.";

return false;

}
but i don't know how to add in this code to lookup the date years in the Date column in the database and compare it with Date entered. i am using in the SQL Query year([Registration_Date]) as column to get what years for the record
Thanks

H
headingwest 5/11/2017

Can you add another column to your table "trans_year"? Then populate it on insert, then have a unique index.

M
maaroufkamel author 5/13/2017



Can you add another column to your table "trans_year"? Then populate it on insert, then have a unique index.


Thanks A lot , I did it