Update records on table using query

Hello, i am using this code that thanks to this forum i am using, now i need to use but in different way

Using this code:

<?php $id = Param("id"); // Get the parameter "id" from $_GET or $_POST $check_id =ExecuteScalar("SELECT employeeid FROM documents WHERE employeeid = '" . $id . "'"); // check the id in "contactunlink" table, assume it is string/varchar/char field type if (empty($check_id)) { // if it does not exist // execute your INSERT INTO SQL $sql = "INSERT INTO documents (employeeid, DocumentName, ExpirationTime,type, exempt) SELECT $id, Docname, ExpirationTime, type, exempt FROM docs"; Execute($sql); } ?>

Using this code i add documents to employees, but what i need is if i add a new document to table docs system just add the new document, now if i run the query system detect the employee id exist and not add the new documents, just work if there is not anu document under this employee id.

the problem is on this part of the code when system check if employeeid exist:

$check_id =ExecuteScalar(“SELECT employeeid FROM documents WHERE employeeid = '” . $id . “'”); // check the id in “contactunlink” table, assume it is string/varchar/char field type
if (empty($check_id)) { // if it does not exist

what i need to do is system check id document name already exist with this employeeid, but when system detect that this employeeid exist with one document, it dont add the other documents

any idea,

thanks?

christ2000 wrote:

what i need to do is system check id document name already exist with this employeeid

If you meant you want to check document name (not employee id), your SQL is incorrect because it selects employeeid:
christ2000 wrote:

$check_id =ExecuteScalar(“SELECT employeeid FROM documents WHERE employeeid = '” . $id . “'”);

yes the problem i dont find a solution to add just the document that not exist

$check_id =ExecuteScalar(“SELECT employeeid FROM documents WHERE employeeid = '” . $id . “'”);

any idea how fix the code?

thanks