Re: Equivelant to mysql_fetch_row for normal array

From: Date: Thu, 22 Jun 2006 17:30:35 +0000
Subject: Re: Equivelant to mysql_fetch_row for normal array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-238518@lists.php.net to get a copy of this message
Jochem, Tul, Nicolas, Thank you for your help. I must be doing something wrong with how my array is generated. It's actually just a MySQL result, but because it is returned from a function, it does not seem to behave as I would expect a MySQL result should. I'm trying the foreach function and key values, but I'm clearly not quite getting it right. Perhaps there is something about my code which is wrong. So I'm presenting what I hope is all the relevant parts: public function getData($row, $type, $column, $match) { $query = "SELECT " . $row . " FROM " . $type . " WHERE " .$column . " = " . $match; echo "query = " . $query . "<br />"; $result = mysql_query($query); $data = mysql_fetch_array($result); return $data; } foreach($elements as $key => $val){ echo "val[type] = " . $val[type] . "<br />"; echo "val[resource] = " . $val[resource] . "<br />"; } What I'm getting back doesn't make sense. I can't go all the way into my code, but $val[type] should be a string value containing the words "Article" or "Text". But instead, I get: val[type] = 2 val[resource] = 2 Am I still not doing the foreach correctly? -- Dave M G

« previous php.general (#238518) next »