Re: displaying duplicate records...
| From: | Bastian Vogt | Date: | Wed, 04 Dec 2002 12:04:41 +0000 |
| Subject: | Re: displaying duplicate records... | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23794@lists.php.net to get a copy of this message | ||
Marco Alting schrieb:
> Ok I see, and how would you catch the error people get, when they send it
> again ?
>
Well, there will be no error-message... if you use mysql (do you?) ;-)
If you want a message you will have to select all rows from your table where the
values the user wants to insert are already inserted. If you find some -> error,
if not -> put them in.
Ignatius is right: I forgot to mention that there mustn't be any duplicates in
the fields you want to add to the unique key.
HTH,
Bastian
>
> "Bastian Vogt" <bastian.vogt@komtel.net> wrote in message
> news:3DEDEB40.17B87F83@komtel.net...
> > Hi,
> >
> > there's an elegant way to stop people from uploading the infos more than
> one
> > time.
> > And it's easy to do. You just have to figure out which fields are not
> allowed to
> > have the same values and put those fields into an unique key.
> > ALTER TABLE projekt ADD UNIQUE(voornaam, achternaam, email)
> > would just allow one entry with the same names and email.
> >
> > The query you're searching may be like this:
> > $query="SELECT COUNT(email) as cnt, voornaam,achternaam,leeftijd,ID,email
> FROM
> > modellen GROUP BY email HAVING cnt >1";
> >
> > HTH,
> > Bastian
> >
> >
> > Marco Alting schrieb:
> >
> > > I have a database which allows people to upload info and foto's. There's
> a
> > > unique ID field, but some people tend to upload their info more than
> once
> > > (its a contest site). What I'm able to do is to see how may duplicates
> there
> > > are using the following statement:
> > >
> > > $query="SELECT COUNT(*) as cnt, voornaam,achternaam,leeftijd,ID,email
> FROM
> > > modellen GROUP BY email HAVING cnt >1";
> > >
> > > But this only gives me numbers. Does anyone know how to display every
> record
> > > that has multiple duplicate ?
> > >
> > > Or is there an elegant way to stop people from entering their info more
> than
> > > once?
> >