I'd like to have a table that has all my site options in it (eg. Site Name, Site URL, etc.) and then an easy way to define variables from it in PHP.
I currently have the table structured like so:
ID _|_ Setting _|_ Value
1 | setting1 | a
2 | setting2 | b
3 | setting3 | c
4 | setting4 | d
I'd like a file that will select each value and define it as a variable in PHP so I can use the variables in my other files. This is what I'm doing for now but it's not a very good way to do it:
$result = mysql_query("SELECT * FROM config WHERE site_option = 'setting1'");
while($row = mysql_fetch_array($result)) {
$pagetitle = $row['value'];
}
$result = mysql_query("SELECT * FROM config WHERE site_option = 'setting2'");
while($row = mysql_fetch_array($result)) {
$siteurl = $row['value'];
}
What would be a better way to do it?