Hi dragon,
your syntax is correct
foreach($rs->fields AS $key => $val) {
//......code
}
and I assume you know if inside a object it would be
foreach($this->fields AS $key => $val) {
//......code
}
or if a instance is made within another object
foreach($this->rs->fields AS $key => $val) {
//......code
}
So basically its a array been traversed and it can only take a array as its first argument, I believe this is without exception
I suspect its the way you have set the array from the sql or the returned object is in fact not a array at all.
I do this real example
$this->statement = NULL;
$this->statement = "SELECT model_id, model_name from model ORDER BY model_name ASC;";
$this->sql->sql_execute($this->statement);
$this->sql->select_rows($this->sql->result);
if($this->sql->rows > 0) {
while($row = mysql_fetch_array($this->sql->result)) {
$this->allModels[$row['model_id']] = $row['model_name'];
}
}
//allModels is ready to be used for the foreach
I would echo out your rs and also check if it is a array as the way you have it the rs appears to be just a sql statement executed.
I hope this helps a little
BBK