Welcome to WebmasterWorld Guest from 54.226.25.231

Forum Moderators: open

Message Too Old, No Replies

help : check if specific record exists

help : check if specific record exists

     

sakala

9:41 pm on Sep 19, 2012 (gmt 0)



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

MichaelBluejay

1:03 pm on Sep 24, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't understand what it is you're asking.

Dijkgraaf

4:12 am on Sep 26, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there a record in siswa that has both the values for nama and nis?
Because that's what your query is looking for?
If you want to see if there is a record where it has either the value for name or the value for nis, you need to have an OR rather than an AND.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month