See http://www.php.net/manual/en/function.mysql-num-rows.php
Kirk
> -----Original Message-----
> From: midget2000x [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 3:00 PM
> To: [EMAIL PROTECTED]
> 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: [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]