I have a database that has information on magazines in a library.
I want to be able to find the first year that we have an issue of the magazine in the database so I wrote the following function:
public function minimum_year($magazine){
$qstring = 'SELECT min(`year`) from `issue` where `magazineid` = '.$magazine;
$result = magdexDB::getInstance()->dbquery($qstring);
while ($row = mysql_fetch_array( $result )){
echo 'Year: '.$row['year'];
}
}
This gives me a result of: Year:
if I change the one line to read: echo 'year:'.$row[0];
then I get: Year: 2004
This is the result I expect. Why can't I use the field name in the $row array?
Is there a function that I could use to show me the field names that are stored in the array?
I have a feeling that this has something to do with the MySQL function min() that I used in the query.
Thanks