[PHP] Newbie database question
I am entering info from form into database, is there a way to check say firstname, lastname and address to see if it is a duplicate to what is already in database and if it is then just enter any new information they may enter and not create a new entry -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] newbie database question
Hi, Thanks in advance if your able to answer this... I run a .txt perl/cgi database/shopping cart which uses the command line http://localhost/_uns/cgi-bin/store.cgi?command=listitems&pos=0&type=all to produce a list of all items in the database. I also have a front page index.htm which has a header and I would like to be able to generate the above output to this page as soon as people visit the site. Is there any way I can do this with PHP. Or at least an someone point me in the right direction. William L Kolln -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie database question
Which database are you using? Dean Ouellette wrote: > I am entering info from form into database, is there a way to check say > firstname, lastname and address to see if it is a duplicate to what is > already in database and if it is then just enter any new information > they may enter and not create a new entry > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "When you have lost the ability to laugh at yourself, you have lost the ability to think straight." --Clarence Darrow "Push the button, Max!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie database question
MySql At 10:10 AM 1/13/2002 -0800, Richard Crawford wrote: >Which database are you using? > > >Dean Ouellette wrote: > >>I am entering info from form into database, is there a way to check say >>firstname, lastname and address to see if it is a duplicate to what is >>already in database and if it is then just enter any new information they >>may enter and not create a new entry > > > >-- >Sliante, >Richard S. Crawford > >mailto:[EMAIL PROTECTED] http://www.mossroot.com >AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford >MSN: [EMAIL PROTECTED] > >"When you have lost the ability to laugh at yourself, you have lost the >ability to think straight." --Clarence Darrow > >"Push the button, Max!" > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie database question
on 1/13/02 10:51 AM, Dean Ouellette at [EMAIL PROTECTED] wrote: > I am entering info from form into database, is there a way to check say > firstname, lastname and address to see if it is a duplicate to what is > already in database and if it is then just enter any new information they > may enter and not create a new entry i'm definitely not an expert on this stuff, but here are some things to think about... on way to keep duplicates from being entered, is to make every (firstname, lastname, address) triplet unique in your database. in mysql, this would be something like ALTER TABLE table_name ADD UNIQUE some_unique_name(firstname, lastname, address); this may not be a good thing though. there may be instances where two folks exist with the same firstname,lastname, address. father/son and mother/daughter perhaps. if you just want to check, you can do something like SELECT id FROM table WHERE firstname = '$firstname' and lastname = '$lastname' and address = '$address'; if you get an id, then a record already exists. the problem with this, is data entry. depending on who is typing the stuff in a form, they may not type/spell it exactly the same each time. you may need to figure out some other unique identifier to determine if it's the 'same' person. hope this helps, mike -- mike cullerton -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie database question
I don't think that there's an easy way to do it in MySQL. I usually use some hack along the lines of, "select x from t where x = $y", and if there are any results returned, return a message of some sort ("That value already exists in the database!"). Bear in mind that sometimes people have very similar contact information. At the university where I used to work, there were two employees who shared the same first, middle, and last names, as well as birth dates, and their social security numbers differed by exactly one digit. A rare circumstance, to be sure, but not impossible. Dean Ouellette wrote: > MySql > > > At 10:10 AM 1/13/2002 -0800, Richard Crawford wrote: > >> Which database are you using? >> >> >> Dean Ouellette wrote: >> >>> I am entering info from form into database, is there a way to check >>> say firstname, lastname and address to see if it is a duplicate to >>> what is already in database and if it is then just enter any new >>> information they may enter and not create a new entry >> >> >> >> >> -- >> Sliante, >> Richard S. Crawford >> >> mailto:[EMAIL PROTECTED] http://www.mossroot.com >> AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford >> MSN: [EMAIL PROTECTED] >> >> "When you have lost the ability to laugh at yourself, you have lost >> the ability to think straight." --Clarence Darrow >> >> "Push the button, Max!" >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "When you have lost the ability to laugh at yourself, you have lost the ability to think straight." --Clarence Darrow "Push the button, Max!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Newbie database question
On 13 Jan 2002, at 12:51, Dean Ouellette wrote: > I am entering info from form into database, is there a way to check > say firstname, lastname and address to see if it is a duplicate to > what is already in database and if it is then just enter any new > information they may enter and not create a new entry If using mysql you can use REPLACE rather than insert (if you also pass a unique key/value with your statement). Of course you have some means of identifying a record. Perhaps it is a combo of firstname, lastname and address but that's not very good. I recall having this situation appear for me in the past ... I think it may be an error in design when one cannot be sure if it's an INSERT for a new record or an UPDATE to an existing record. Perhaps you could dissuage me otherwise with your example. Peter --- "Reality is that which, when you stop believing in it, doesn't go away". -- Philip K. Dick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]