Hi everybody,
just would like to ask to someone more expert than me if it's possible to use a variable (or maybe better, array) as name of the column from which I should get the results with the query.
So I mean instead of this:
... something like this
Ok, this doesn't work... but is there maybe some other way...?
Thanks
just would like to ask to someone more expert than me if it's possible to use a variable (or maybe better, array) as name of the column from which I should get the results with the query.
So I mean instead of this:
Code:
while ($results = mysql_fetch_array($query)) {
$id = $results['id'];
$name = $results['name'];
...
}
Code:
$fields = array("id","name", ...);
$i = 0;
while ($results = mysql_fetch_array($query)) {
$id = $results[$fields[$i]];
$name = $results[$fields[$i]];
...
$i++
}
Thanks
Comment