Re: Equivelant to mysql_fetch_row for normal array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux