This topic is locked

any ideas? for events!

8/3/2006 3:47:40 PM
PHPRunner General questions
A
amirgulamali author

I am trying to add records in a table(_1ee0) using my own code from another page (_students):
$strSQLSave = "INSERT INTO _1ee0 (StudentNumber, FirstName, Email, LastName) values (";
$strSQLSave .= $values["StudentNumber"].",";

$strSQLSave .= $values["FirstName"].",";

$strSQLSave .= $values["Email"].",";

$strSQLSave .= $values["LastName"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
Now I am using events to avoid duplication of records where each record has a unique student number using

****check if record exists**
is there any way I could *check if record exists ** in _1ee0 events page (which also doesnt have the ADD NEW function)... hence I cannot use the Before Add() check if record exits event!
Is there any other type of header for ****check if record exists** since im not adding records teh normal way, I am using records using the above code in BLUE! thanx

J
Jane 8/8/2006

Amir,
try to use following code:

global $conn;

$strSQLExists = "select * from _1ee0 where StudentNumber=".$values["StudentNumber"];

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

$data=db_fetch_array($rsExists);

if($data)

{

echo "this student number exist";

return false;

}

else

{

$strSQLSave = "INSERT INTO _1ee0 (StudentNumber, FirstName, Email, LastName) values (";
$strSQLSave .= $values["StudentNumber"].",";

$strSQLSave .= $values["FirstName"].",";

$strSQLSave .= $values["Email"].",";

$strSQLSave .= $values["LastName"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);

return true;

}