Currently, all my script settings are in a PHP file, which I 'include'. I move these settings (about 100) to a database table called “settings”. However, I am struggling to find an efficient way to extract all of them into a file.
The settings table contains 3 columns:
- ID (auto increment)
- name
- value
Two examples could be:
admin_user john
admin_email_address john@example.com
The only way I can find each parameter is as follows:
$result = mysql_query("SELECT value FROM settings WHERE name = 'admin_user'");
$row = mysql_fetch_array($result);
$admin_user = $row['value'];
$result = mysql_query("SELECT value FROM settings WHERE name = 'admin_email_address'");
$row = mysql_fetch_array($result);
$admin_email_address = $row['value'];
etc.
Running this method will take a lot of code and will probably be slow.
Is there a better way?