RE: [PHP] coding for 'no match found'

From: Date: Tue, 15 May 2001 22:16:33 +0000
Subject: RE: [PHP] coding for 'no match found'
Groups: php.general 
Request: Send a blank email to php-general+get-52945@lists.php.net to get a copy of this message
See http://www.php.net/manual/en/function.mysql-num-rows.php Kirk > -----Original Message----- > From: midget2000x [mailto:midget@elaris.com] > Sent: Tuesday, May 15, 2001 3:00 PM > To: php-general@lists.php.net > Subject: [PHP] coding for 'no match found' > > > This is a simple yet fundamental programming question I am > hoping somebody will > have the patience to explain... > > I have a mysql database with the "email" field as the key. > Before inserting an > new record to it I want to check if there is already a record > with that e-mail. > This I can do fine. But this script needs to also handle > delete requests, > which I can also do fine, but I need to code for the instance > that there is a > delete request for an e-mail record that does not exist. How > can I figure out > if after my 'while' loop is finished checking the database it > has not found a > match (so i can inform the requester as such)? > > Here's the code I have so far... > > $email_check_query = "SELECT email FROM > $tablename WHERE email = '$email'"; > $email_check_result = mysql_query($email_check_query); > while($email_query_data = > mysql_fetch_array($email_check_result)) { > $db_email = $email_query_data["email"]; > //if match, it's an update or delete > if ($email==$db_email) { > if ($op=="delete") { > $action="del"; > echo "delete > request<br>"; > } > else { > $action = "upd"; > echo "update > request<br>"; > } > } > } //end while loop > > ----------- > providing the finest in midget technology > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.general (#52945) next »