Jump to content


Photo

checking for duplicates


  • Please log in to reply
2 replies to this topic

#1 leeroy1

leeroy1
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 06 October 2004 - 01:23 PM

Is it possible to execute a sql statement or something in order to check if a field a user has enter already exists in a table, and if it does tells the user and does not try to submit the form? Or is there a better way to do this?

#2 x_ash

x_ash
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 October 2004 - 03:01 AM

i think mysql statement can already detect if a certain user enters a field that already exists. I has a prompt saying "Duplicate entry" on it. If u want it more formal, you may add message box on it using javascript.

hope this help :mellow:

#3 jerry187

jerry187
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationAustralia

Posted 07 October 2004 - 04:49 AM

Do you mean looking for a value and telling the user if it already exists?

$result = mysql_query("SELECT column_name FROM tbl_name WHERE column_name='$value'");

if (!mysql_num_rows($result > 0) {
// code here
}

Just Call Me Jerry




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users