Checking for multiple database entries

Reply

Join Date: Jun 2004
Posts: 19
Reputation: Syneticus can only hope to improve 
Solved Threads: 0
Syneticus Syneticus is offline Offline
Newbie Poster

Checking for multiple database entries

 
0
  #1
Jun 10th, 2004
Hey, I've written a script in PHP that writes data into a MySQL database upon request, but what I'd also like to include is a script that will go in after the request is made, and check to make sure that the same entry does not already exist... and I have no clue where to start. I've never tried to do anything like this before, and am not sure what to do. If I could get some ideas from anyone it would be greatly appreciated. Thanks!
Reply With Quote Quick reply to this message  
Join Date: Feb 2002
Posts: 1,135
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Solved Threads: 6
Team Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor

Re: Checking for multiple database entries

 
0
  #2
Jun 10th, 2004
All you have to do is run a select statement looking for the value you just inserted. This goes right after your insert statement.

  1. Here's some pseudo code:
  2.  
  3. 1. insert into table(field1) values('value')
  4. 2. y = select count(field1) from table where field1 = 'value'
  5. 3. if (y == 1)
  6. just one exists
  7. elseif( y > 1)
  8. multiple exist
  9.  

If you need more help let us know.
Check out my blog at http://www.shinylight.com for more stuff about web dev.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC