Hello,
I currently use the following code to put data out of my table and assign to an array.
$q = mysql_query("SELECT * FROM config");
while ($row = mysql_fetch_array($q)) {
$fid = $row['config_description'];
$main_var[$fid] = $row['config_value'];
}
I am looking to put the query into a separate function, return the mysql result array to which I can then work with assign the values to an array.
I have tried several ways but I have no luck and keep getting stuck on what is passed back from the function. What I have put below is what I am trying to achieve and I know it does not work, anyone know how the code can be corrected below to make it work, Thanks
function get_config_mysql() {
$q = mysql_query("SELECT * FROM config");
return mysql_fetch_array($q);
}
$q = get_config_mysql();
while ($row = $q) {
$fid = $row['config_description'];
$main_var[$fid] = $row['config_value'];
}