This topic is locked

Checking for Multiple dups & Allowing empty field

7/6/2017 3:32:20 PM
PHPRunner General questions
N
nti author

from xlinesoft help files:
And if we have multiple fields to check? how can we do an array of fields? or do we duplicate the code for each duplicated field ?
//** Check if specific record exists ****


$strSQLExists = "select * from AnyTable where AnyColumn='SomeValue'";

$rsExists = db_query($strSQLExists);

$data=db_fetch_array($rsExists);

if($data)

{

// if record exists do something

}

else

{

// if dont exist do something else

}
admin 7/11/2017

You will need to learn the power of SQL to implement functionality like this. For instance you have Employees table with fields FirstName and LastName. To find employees with the same first name and last name use the following query:

select * from employees where FirstName='Andrew' and LastName='Smith'


To find all employees with the same first name or last name use the following:

select * from employees where FirstName='Andrew' or LastName='Smith'


Most likely the first scenario is what you looking for.
More info:

https://www.w3schools.com/sql/sql_and_or.asp