Topic awaiting preservation: PHP MYSQL database checking - help |
|
---|---|
Author | Thread |
Obsessive-Compulsive (I) Inmate From: |
posted 06-09-2004 02:27
is there a way to check an entry via a form with an entry in a database. I have a form which enters new data into a database and need to check to see if an entry already exists with the same id number. On the form i have child details and parent details, I need to check to see if parent id already exists, if yes, do not add parent details but continue with child details. If no, add both child and parent. I have the insert queries already but am stuck on this problem. |
Maniac (V) Inmate From: under the bed |
posted 06-09-2004 02:56
There may be a better way, but you can jsut do a query on the relevant table, searching for the parent id. If a match is found, do a, if not, do b. |
Bipolar (III) Inmate From: Australia |
posted 06-09-2004 06:18
Yeh a query would be the way i think, im not sure wiht msql coz i mostly use ms access databases, but if its an indexed column then this wouldnt take very long. |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 06-09-2004 06:47
There are a couple of ways to do this and it is really code dependent. |
Bipolar (III) Inmate From: |
posted 06-09-2004 14:50
You all are talking about the php doing the work...and that's probably how I'd do it. |
Obsessive-Compulsive (I) Inmate From: |
posted 06-11-2004 20:27
thanks for the help everyone, I finally got it finished. What I did was inserted the child details then I queried the database and got a count(*) where parentid = the entered id number. then if the count was = 1, update the child table with the parent id number, if count = 0, add parent info then update child table. I learnt so much about mysql doing this project you guys wouldn't believe me. |
Maniac (V) Inmate From: under the bed |
posted 06-12-2004 00:00
Seems a little akward to me. |