Re: [PHP] How to replace define in a require file with mysql?
2007. 11. 5, hétfő keltezéssel 06.10-kor Ronald Wiplinger ezt írta: Jim Lucas wrote: Ronald Wiplinger wrote: I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald Well, if you have all the settings in a DB already, then what I would do is this. SELECT param_name, param_value FROM yourTable; then while ( list($name, $value) = mysql_fetch_row($results_handler) ) { define($name, $value); } put this in place of your existing defines and you should be good. Thanks! Works fine! I need now a modification for that. Two values: SELECT param_name, param_value1, param_value2 FROM yourTable; IF param_value1 is empty, than it should use param_value2 try something like this sql: SELECT param_name, IF ((param_value1 '') AND NOT ISNULL(param_value1), param_value1, param_value2) AS param_value FROM yourTable greets Zoltán Németh How can I add this? Thank you again. bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to replace define in a require file with mysql?
On 05/11/2007, Zoltán Németh [EMAIL PROTECTED] wrote: 2007. 11. 5, hétfő keltezéssel 06.10-kor Ronald Wiplinger ezt írta: Jim Lucas wrote: Ronald Wiplinger wrote: I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald Well, if you have all the settings in a DB already, then what I would do is this. SELECT param_name, param_value FROM yourTable; then while ( list($name, $value) = mysql_fetch_row($results_handler) ) { define($name, $value); } put this in place of your existing defines and you should be good. Thanks! Works fine! I need now a modification for that. Two values: SELECT param_name, param_value1, param_value2 FROM yourTable; IF param_value1 is empty, than it should use param_value2 try something like this sql: SELECT param_name, IF ((param_value1 '') AND NOT ISNULL(param_value1), param_value1, param_value2) AS param_value FROM yourTable or use COALESCE() (http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce) SELECT param_name, COALESCE(param_value1, param_value2) AS param_value FROM yourTable; -robin
Re: [PHP] How to replace define in a require file with mysql?
Ronald Wiplinger wrote: Jim Lucas wrote: Ronald Wiplinger wrote: I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald Well, if you have all the settings in a DB already, then what I would do is this. SELECT param_name, param_value FROM yourTable; then while ( list($name, $value) = mysql_fetch_row($results_handler) ) { define($name, $value); } put this in place of your existing defines and you should be good. Thanks! Works fine! I need now a modification for that. Two values: SELECT param_name, param_value1, param_value2 FROM yourTable; IF param_value1 is empty, than it should use param_value2 How can I add this? Thank you again. bye Ronald In PHP i would do it like this. while ( list($name, $value1, $value2) = mysql_fetch_row($results_handler) ) { define($name, ( empty($value1) ? $value2 : $value ) ); } -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to replace define in a require file with mysql?
Jim Lucas wrote: Ronald Wiplinger wrote: I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald Well, if you have all the settings in a DB already, then what I would do is this. SELECT param_name, param_value FROM yourTable; then while ( list($name, $value) = mysql_fetch_row($results_handler) ) { define($name, $value); } put this in place of your existing defines and you should be good. Thanks! Works fine! I need now a modification for that. Two values: SELECT param_name, param_value1, param_value2 FROM yourTable; IF param_value1 is empty, than it should use param_value2 How can I add this? Thank you again. bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to replace define in a require file with mysql?
I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to replace define in a require file with mysql?
I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to replace define in a require file with mysql?
I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? I'm not aware of any method of undefining an already defined constant. Except changing the line in your required file... -- Richard Heyes +44 (0)800 0213 172 http://www.websupportsolutions.co.uk Knowledge Base and HelpDesk software that can cut the cost of online support -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to replace define in a require file with mysql?
Ronald Wiplinger wrote: I have a file linked with require into my program with statements like: define(_ADDRESS,Address); define(_CITY,City); I would like to replace this with a mysql table with these two fields (out of many other fields). How can I do that? bye Ronald Well, if you have all the settings in a DB already, then what I would do is this. SELECT param_name, param_value FROM yourTable; then while ( list($name, $value) = mysql_fetch_row($results_handler) ) { define($name, $value); } put this in place of your existing defines and you should be good. -- Jim Lucas Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them. Twelfth Night, Act II, Scene V by William Shakespeare -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php