It looks very much as if you did:

update members set member_name = 'N/A' where member_name = null

Nevertheless, I would rather keep null within the database and use 'N/A' at the presentation level. My rule is that the data in the database should be in a machine oriented format. For example, I store timestamps, never formated dates, numbers as actual numerical datatypes, not as strings, though PHP can cope with either. 'N/A' is a way to present that information to the user, which might even be, for example, language dependant.

On displaying, you could well do:

SELECT member_id, ifnull(member_name,'N/A') FROM members

Satyam


----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <php-general@lists.php.net>
Sent: Wednesday, June 14, 2006 11:37 PM
Subject: [PHP] can I do this: update table while selecting data from table?


Am I allowde to do this:

$query = mysql_query("SELECT member_id, member_name FROM members");
while($result = mysql_fetch_array($query))
{
 if(empty($result['member_name']))
 {
   mysql_query("UPDATE members SET member_name = 'N/A' WHERE member_id =
".$result['member_id']."");
 }
}

As far as I know, after "SELECT" query, data are in buffer and I AM able
to connect to the same table and do UPDATE, right?

Thanks

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to