AtomicRax Posted June 21, 2009 Share Posted June 21, 2009 Ok, here's what I have: A MySQL table named "settings" with two fields- "name" and "value" I have a query that looks like this: $query = mysql_query("SELECT * FROM settings"); $settings = mysql_fetch_array($query, MYSQL_ASSOC); (Currently there is only one result, but it will not stay this way.) What I want to do: Call any of the settings by their name... Like $settings[example] = "my value". How ever, with this current code, $settings[name] = "example" and $settings[value] = "my value" Any help? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/163108-solved-fetch-array/ Share on other sites More sharing options...
trq Posted June 21, 2009 Share Posted June 21, 2009 $settings = array(); if ($result = mysql_query("SELECT value FROM settings WHERE name = '$key'")) { if (mysql_num_rows($result)) { while ($row = mysql_fetch_assoc($result)) { $settings[$row['name']] = $row['value']; } } } echo $settings['example']; Quote Link to comment https://forums.phpfreaks.com/topic/163108-solved-fetch-array/#findComment-860579 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.