scarhand Posted July 4, 2007 Share Posted July 4, 2007 I have these selections in 1 file that the user is able to configure themselves via a form in their control panel....I've got it all working but I was wondering if this is a good way of doing it or not... $bandnamesql = mysql_query("SELECT * FROM config WHERE config_name = 'bandname'"); while($row = mysql_fetch_array($bandnamesql)) { $bandname = $row['config_value']; } $copyrightsql = mysql_query("SELECT * FROM config WHERE config_name = 'copyright'"); while($row = mysql_fetch_array($copyrightsql)) { $copyright = $row['config_value']; } I posted this in the PHP help forum by accident and someone said something about using "OR" for the last 2 selections to increase performance...any help would be appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/58425-solved-is-this-a-valid-mysql-selection/ Share on other sites More sharing options...
scarhand Posted July 4, 2007 Author Share Posted July 4, 2007 I started messing around a bit, and am now using this: $configsql = mysql_query("SELECT * FROM config WHERE config_name = 'bandname' OR config_name = 'copyright' "); while($row = mysql_fetch_array($configsql)) { if ($row['config_name'] == 'bandname') { $bandname = $row['config_value']; } if ($row['config_name'] == 'copyright') { $copyright = $row['config_value']; } } This look better? Quote Link to comment https://forums.phpfreaks.com/topic/58425-solved-is-this-a-valid-mysql-selection/#findComment-289694 Share on other sites More sharing options...
gizmola Posted July 4, 2007 Share Posted July 4, 2007 I'm confused... where is the column that indicates which band these settings are pertinent to, or is this a cms application where the assumption is that someone will run this application on their website? The answer to your specific question is that I would probably just select all settings, and I would write a routine that would read all these settings into an array. With that said, if you want to stay with what you have, the 2nd approach is definately an improvement (one query vs. 2) . Quote Link to comment https://forums.phpfreaks.com/topic/58425-solved-is-this-a-valid-mysql-selection/#findComment-289956 Share on other sites More sharing options...
scarhand Posted July 5, 2007 Author Share Posted July 5, 2007 I'm confused... where is the column that indicates which band these settings are pertinent to, or is this a cms application where the assumption is that someone will run this application on their website? The answer to your specific question is that I would probably just select all settings, and I would write a routine that would read all these settings into an array. With that said, if you want to stay with what you have, the 2nd approach is definately an improvement (one query vs. 2) . Well I am really new to PHP and MySQL, so I have made it so this would be run as a bands web site. I will look into arrays and MySQL selections to improve my code, thanks for the input. Quote Link to comment https://forums.phpfreaks.com/topic/58425-solved-is-this-a-valid-mysql-selection/#findComment-290779 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.