DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   PHP (http://www.daniweb.com/forums/forum17.html)
-   -   Checking for multiple database entries (http://www.daniweb.com/forums/thread6861.html)

Syneticus Jun 10th, 2004 4:43 pm
Checking for multiple database entries
 
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!

samaru Jun 10th, 2004 6:51 pm
Re: Checking for multiple database entries
 
All you have to do is run a select statement looking for the value you just inserted. This goes right after your insert statement.

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

If you need more help let us know.


All times are GMT -4. The time now is 7:42 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC