Re: can I do this: update table while selecting data from table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



afan@xxxxxxxx wrote:
> 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?

no you'll have to reboot the machine first.








seriously though, have you tried it?

that said your [probably] better off just doing 1 query:

	UPDATE members SET member_name = 'N/A' WHERE member_name = '';

that said your [probably] better off leaving the name empty or setting it NULL if
it's unknown and showing 'N/A' in whatever output screen it's relevant for any
names that are found to be empty.

> 
> Thanks
> 
> -afan
> 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux