Welcome to WebmasterWorld Guest from 54.198.210.67

Forum Moderators: open

Message Too Old, No Replies

help : check if specific record exists

help : check if specific record exists

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

New User

5+ Year Member

joined:Sept 18, 2012
posts: 2
votes: 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
1:03 pm on Sept 24, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 12, 2003
posts: 1199
votes: 0


I don't understand what it is you're asking.
4:12 am on Sept 26, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 31, 2005
posts:1108
votes: 0


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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members