Welcome Guest, Not a member yet? Register   Sign In
foreach that has no value

this has been my problem now because some of my data should be null
my problem is when I have null values i encounter this error

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/index.php

Line Number: 91

I wonder how to redirect this error to <?php echo No message found ?> or just blank without any error

my views
<?php foreach ($verses as $verseItem):?>
<?php echo form_open('church/verses'); ?>
&lt;?php echo $verseItem->title ?&gt;</th>
&lt;?php echo $verseItem->message ?&gt;
&lt;?php endforeach?&gt;
&lt;?php echo form_close();?&gt;

function home() {
$data['verses'] = $this->m_church->gethomeverse();
$this->load->view('index', $data);

public function gethomeverse () {
$query = $this->db->get('tb_verse');
if($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$data[] = $row;
return $data;
Thanks in advance

Theme © iAndrew 2016 - Forum software by © MyBB