Its might sounding like a noob question but I can't find an answer. Currently I have this.
$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$gridData[] = array(
'CompanyName' => $row['CompanyName'],
'ContactName' => $row['ContactName'],
'ContactTitle' => $row['ContactTitle'],
'Address' => $row['Address'],
'Country' => $row['Country'],
'Parent' => $row['Parent'],
'City' => $row['City'],
'id' => $row['id']
);
}
but assuming I don't want to hardcode this fields there I have another array which is stored in $fields and has the structure of an array inside so field [0] is the fieldname.
so I do
foreach ($fields as $field)
{
$gridData[$field[0]] => $row[$field[0]];
}
by some reason it does not work like this. what is the way to do this properly? How can I bring this together?