Currently all of my script's settings are located in a PHP file which I 'include'. I'm in
the process of moving these settings (about 100) to a database table called 'settings'. However I'm struggling to find an efficient way of retrieving all of them into
the file.
The settings table has 3 columns:
ID (autoincrements)
name
value
Two example rows might be:
1
admin_user
john
2
admin_email_address
[email protected]
The only way I can think of retrieving each setting is like this:
$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 etc
Doing it this way will take up a lot of code and will likely be slow.
Is there a better way?
Thanks.