Current location: Hot Scripts Forums » Programming Languages » PHP » Submit data - check for duplicate/delete duplicate from database


Submit data - check for duplicate/delete duplicate from database

Reply
  #1 (permalink)  
Old 03-15-09, 09:44 PM
Drbbest Drbbest is offline
New Member
 
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Submit data - check for duplicate/delete duplicate from database

I'm using dreamweaver (yes, laugh)

Before a user submits data to mysql, I want to have the .php page:
check for and remove duplicate entries before the data is entered into the database.



I have don't know how to go about doing this. Thanks for your help!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-16-09, 06:12 AM
landing's Avatar
landing landing is offline
Coding Addict
 
Join Date: Jul 2006
Location: Scotland
Posts: 302
Thanks: 0
Thanked 0 Times in 0 Posts
The code would be something like

PHP Code:

$check mysql_query("SELECT * FROM `table` WHERE `field` = '$value'");

if (
mysql_num_rows($check) > 0) {
     
// Duplicate exists. Remove it
     
mysql_query("DELETE FROM `table` WHERE `field` = '$value' LIMIT 1");
}

// Insert new data
mysql_query("INSERT INTO `table` (`field1`) VALUES ('$value1')"); 
__________________
Always sanitise your data


Best regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to retrieve data from database Shankarandy ASP 2 06-30-07 04:01 PM
How to recover sql server database data? method Database 3 06-20-07 08:11 PM
Do you know the idea of fetch data from Html by PHP and save it to database ? sharif_aly PHP 13 02-23-07 10:20 PM
Want to check in the database if the txn_id has been used before Oskare100 PHP 8 10-30-06 12:01 PM
how to display data from database hubby ASP 1 07-31-06 08:07 AM


All times are GMT -5. The time now is 10:09 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.