homepage Welcome to WebmasterWorld Guest from 54.234.141.47
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

    
help : check if specific record exists
help : check if specific record exists
sakala



 
Msg#: 4497516 posted 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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 4497516 posted 1:03 pm on Sep 24, 2012 (gmt 0)

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

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4497516 posted 4:12 am on Sep 26, 2012 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved