Re: [PHP] can I do this: update table while selecting data from table?
[EMAIL PROTECTED] wrote: ?!?!?!?!?!?! I hope youi used str_repeat() to generate that. 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this: update table while selecting data from table?
I wonder why this sarcasm? Why so rude? -afan [EMAIL PROTECTED] wrote: ?!?!?!?!?!?! I hope youi used str_repeat() to generate that. 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 -- 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
Re: [PHP] can I do this: update table while selecting data from table?
Jochem, You are wrong. I tried and it worked. But, when I asked can I, I meant Am I allowed to do that. The same as many security or other kind questions where answer is: Yes, it works - but it's NOT correct. Yes, I did search php.net but didn't find answer. Yes, I did search mysql.com but didn't find answer. (Hm, maybe I had to spend few more days before I'm ALLOWED to post a question here) And, please, if you DON'T WANT to help - don't answer at all. Believe me, your kind of answer REALLY do not help. Contrary, brings this kind of conversation what this great group really doesn't need. Thanks. -afan [EMAIL PROTECTED] wrote: I wonder why this sarcasm? Why so rude? your original question could have been answered by: a, trying to run the code provided (thats called testing btw) b, reading php.net c, reading mysql.com/docs (or where ever they have the docs this week) my reply not only contained the blantantly silly suggestion that you had to reboot the machine but also seriously asked if you had tried to run the code (I can garantee that you had not because then you would have know that it did work with out posting here) AND I offered 2 suugestions as to why the strategy you were employing for the routine sucked - one performance related, one with regard to DB/data theory. and all you could come up with as a response was '?!?!?!?!?!?!' you want spoonfeeding, try kindergarten. -afan [EMAIL PROTECTED] wrote: ?!?!?!?!?!?! I hope youi used str_repeat() to generate that. 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 -- 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
Re: [PHP] can I do this: update table while selecting data from table?
[EMAIL PROTECTED] wrote: You are wrong. there's a first for everything, heh. I tried and it worked. But, when I asked can I, I meant Am I allowed to do that. The same as many security or other kind then say what you mean in future. you already knew that you *can* do it, you should have asked 'is this wise' - which would have led to a different response namely: in general nothing wrong with it, in your particular case it seems INEFFICIENT. questions where answer is: Yes, it works - but it's NOT correct. there is nothing technically incorrect about perform a query whilst looping the results of a different query btw. Yes, I did search php.net but didn't find answer. Yes, I did search mysql.com but didn't find answer. (Hm, maybe I had to spend few more days before I'm ALLOWED to post a question here) your allowed to post whenever you want. And, please, if you DON'T WANT to help - don't answer at all. Believe me, your kind of answer REALLY do not help. Contrary, brings this kind of conversation what this great group really doesn't need. REALLY I don't care what you think. you control what you post I control what I post and not vice versa. Thanks. for bruising your ego? or for originally giving 2 suggestions as to better strategies for doing what you *seemed* to be wanting to achieve - 2 suggestions which you blatantly seemed to ignore in favor of moaning about your bruised ego. en fin. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this: update table while selecting data from table?
[EMAIL PROTECTED] wrote: I wonder why this sarcasm? Why so rude? your original question could have been answered by: a, trying to run the code provided (thats called testing btw) b, reading php.net c, reading mysql.com/docs (or where ever they have the docs this week) my reply not only contained the blantantly silly suggestion that you had to reboot the machine but also seriously asked if you had tried to run the code (I can garantee that you had not because then you would have know that it did work with out posting here) AND I offered 2 suugestions as to why the strategy you were employing for the routine sucked - one performance related, one with regard to DB/data theory. and all you could come up with as a response was '?!?!?!?!?!?!' you want spoonfeeding, try kindergarten. -afan [EMAIL PROTECTED] wrote: ?!?!?!?!?!?! I hope youi used str_repeat() to generate that. 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 -- 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
Re: [PHP] can I do this: update table while selecting data from table?
At 4:11 PM +0200 6/15/06, [EMAIL PROTECTED] wrote: Jochem, You are wrong. I tried and it worked. But, when I asked can I, I meant Am I allowed to do that. The same as many security or other kind questions where answer is: Yes, it works - but it's NOT correct. Yes, I did search php.net but didn't find answer. Yes, I did search mysql.com but didn't find answer. (Hm, maybe I had to spend few more days before I'm ALLOWED to post a question here) And, please, if you DON'T WANT to help - don't answer at all. Believe me, your kind of answer REALLY do not help. Contrary, brings this kind of conversation what this great group really doesn't need. Thanks. -afan -afan: You should keep this in mind while posting. People, like Jochem, are here to help you with no reward except that they are helping others. They spend their time reading your post and trying to provide you with guidance from their experience. I can't speak for Jochem, but sometimes what we post doesn't come across as well as we intended. I know I've pissed-off some people on this list and I regret that, even though it was unintentional. So, try to give those who try to help you a bit slack. Permit them the right to tell you to RTFM or whatever else they think will help you. Granted, sometimes we don't want to hear what our problem is, but that's what happens when you post to a list asking for help. So, cut us all a bit of slack and we'll all be better for it. tedd -- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this: update table while selecting data from table?
Yes, you are right, I had to be more carefull about how to write my post. Thanks. for bruising your ego? or for originally giving 2 suggestions as to better strategies for doing what you *seemed* to be wanting to achieve - 2 suggestions which you blatantly seemed to ignore in favor of moaning about your bruised ego. Since you didn't get it, Thanks is part of polite communication between people. -afan [EMAIL PROTECTED] wrote: You are wrong. there's a first for everything, heh. I tried and it worked. But, when I asked can I, I meant Am I allowed to do that. The same as many security or other kind then say what you mean in future. you already knew that you *can* do it, you should have asked 'is this wise' - which would have led to a different response namely: in general nothing wrong with it, in your particular case it seems INEFFICIENT. questions where answer is: Yes, it works - but it's NOT correct. there is nothing technically incorrect about perform a query whilst looping the results of a different query btw. Yes, I did search php.net but didn't find answer. Yes, I did search mysql.com but didn't find answer. (Hm, maybe I had to spend few more days before I'm ALLOWED to post a question here) your allowed to post whenever you want. And, please, if you DON'T WANT to help - don't answer at all. Believe me, your kind of answer REALLY do not help. Contrary, brings this kind of conversation what this great group really doesn't need. REALLY I don't care what you think. you control what you post I control what I post and not vice versa. Thanks. for bruising your ego? or for originally giving 2 suggestions as to better strategies for doing what you *seemed* to be wanting to achieve - 2 suggestions which you blatantly seemed to ignore in favor of moaning about your bruised ego. en fin. -- 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
Re: [PHP] can I do this: update table while selecting data from table?
[EMAIL PROTECTED] 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
Re: [PHP] can I do this: update table while selecting data from table?
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
Re: [PHP] can I do this: update table while selecting data from table?
?!?!?!?!?!?! [EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can I do this: update table while selecting data from table?
No, that was just an exapmle to explain better. Of course this is not the REAL code. :) And there are some more thing to do inside while loop. Thanks. -afan 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php