Re: Checking Records in the database and then adding.

From: Date: Sun, 27 Aug 2000 10:33:01 +0000
Subject: Re: Checking Records in the database and then adding.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2399@lists.php.net to get a copy of this message
hi, the solution looks like this: 1.) get the loginID of the user by submitting the formdata ( lets call it: $submittedID ) 2.) execute a query to the database ...something like: SELECT loginID FROM yourTable WHERE loginID = '$submittedID' 3.) now do some simple if else statement: If (NO ROWS) { perform an INSERT-query to the database } else { loginID okay so lets go further } the exact code depens on the database you are using and the type of connection. _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/_/ viva technologies _/ gstrein andreas "Always listen to the experts; they'll tell you what can't be done and why. Then do it." - Robert A. Heinlein > Hi PHP Gurus! > > I have a little problem in database. I want to add a loginID to my mysql > database. As login ID is something unique, I want to first check the records > in the database and see if the loginID someone is entering to database > already exists. If it exisits, a message should be given else a record > should be added. > > If ASP we do it as below. > > If Rs.Eof Then > AddNew > Else > Response.Write Error > End If > > Now this is what I want in PHP. > > Please help. > > Thanks in advance! > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#2399) next »