Forum Moderators: coopster

Message Too Old, No Replies

How can I determine if a record exists?

         

sakala

6:27 pm on Sep 18, 2012 (gmt 0)

10+ Year Member



This is my code "Check If Specific Record Exist" with 1 values and everything goes fine

global $conn;
$strSQLExists = "select * from siswa where nama='".$values["nama"]."'";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);
if($data)
{
// if the record exists
$message="<div class=message><<< "."Database NOT updated ......The name entered already exists.....Use another name"." >>></div>";
return false;
}
else
{


return true;
}

but with this code

$strSQLExists = "select * from siswa where nama='".$values["nama"]."' AND nis='".$values["nis"]."'";
or
select * from kelas where nama='$values['nama']' AND nis='$values['nis']'


The $values["nis"] still record after added

Please help me, how to avoid record exist for nama and nis values.

Thank You so much

coopster

9:23 pm on Jan 20, 2013 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Cross-post, see [webmasterworld.com...]