943,608 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4056
  • PHP RSS
Jun 10th, 2004
0

Checking for multiple database entries

Expand Post »
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!
Similar Threads
Reputation Points: 23
Solved Threads: 0
Newbie Poster
Syneticus is offline Offline
19 posts
since Jun 2004
Jun 10th, 2004
0

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.

PHP Syntax (Toggle Plain Text)
  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.
Team Colleague
Reputation Points: 262
Solved Threads: 18
a.k.a inscissor
samaru is offline Offline
1,227 posts
since Feb 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Reseller script
Next Thread in PHP Forum Timeline: making own webmail





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC