|
|||
|
Hello,
I am trying to retrieve data from a MYSQL table but I am getting the following error: Code:
Warning: Invalid argument supplied for foreach() in C:\wamp\www\zendpro\application\views\indexIndex.php on line 16 in the index.php file, I inserted the following. I have an .ini file which holds the database connection settings. Code:
// setup database
$db = Zend_Db::factory($config_db->db->adapter, $config_db->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
Code:
<?php
class Album extends Zend_Db_Table {
protected $_name = 'album';
}
?>
Code:
Zend_Loader::loadClass('Album');
$album = new Album();
$this->view->albums = $album->fetchAll();
Code:
<?php foreach($this->view->albums as $album) : ?> <tr> <td><?php echo $this->escape($album->title);?></td> <td><?php echo $this->escape($album->artist);?></td> <td> <a href="<?php echo $this->baseUrl; ?>/index/modify/id/<?php echo $album->id;?>">Modifier</a> <a href="<?php echo $this->baseUrl; ?>/index/delete/id/<?php echo $album->id;?>">Supprimer</a> </td> </tr> <?php endforeach; ?> I would appreciate if anyone could kindly help me. Regards |
![]() |
| Thread Tools | |
| Display Modes | |
|
|