Hello iam new to joomla  creating a module mod_testimonial. I this have put the data into $rows = $db->loadObjectList(); from the helper file,
and the the data in the $rows after echo is
Array
(
    [0] => stdClass Object
        (
            [name] => james
            [testimonial] => Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
            [regdate] => 2013-12-31 13:24:29
            [id] => 37
        )
    [1] => stdClass Object
        (
            [name] => Tom
            [testimonial] => Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            [regdate] => 2013-12-31 14:45:56
            [id] => 38
        )
    [2] => stdClass Object
        (
            [name] => Alyson
            [testimonial] => is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
            [regdate] => 2014-01-03 14:52:09
            [id] => 42
        )
)
in my default.php file the i had fetched the data from array as like this.
 <p><?php print_r($rows[0]->testimonial);?><span class="testimonial-by"> —<?php print_r($rows[0]->name);?>,<?php echo date('M Y',strtotime($rows[1]->regdate)); ?>,</span></p>
  <p><?php print_r($rows[1]->testimonial);?><span class="testimonial-by">—<?php print_r($rows[1]->name);?>,<?php echo date('M Y',strtotime($rows[2]->regdate)); ?>,</span></p>
<p><?php print_r($rows[2]->testimonial);?><span class="testimonial-by">—<?php print_r($rows[2]->name);?>,<?php echo date('M Y',strtotime($rows[0]->regdate)); ?>,</span></p>
my helper file is
static function getRecord($params)
    {
        $db = JFactory::getDBO();
        $query = "SELECT name,testimonial,regdate,id FROM #__testimonial WHERE published = '1' AND featured='1' ";
        $db->setQuery( $query);
        $rows = $db->loadObjectList();
        return $rows;
    }
.Till here its all okk but if i will unpublish or unfeatured the data from the back end it will raise an error like this
Notice: Undefined offset: 2 in modules\mod_testimonial\tmpl\default.php on line 37
Notice: Trying to get property of non-object in modules\mod_testimonial\tmpl\default.php on line 37
File not found
i know this is because there is no
offset [2] => stdClass Object
        (
            [name] => Alyson
            [testimonial] => is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
            [regdate] => 2014-01-03 14:52:09
            [id] => 42
        )
i want to give a proper loop so that this problem skips and i do not need to change my template.
please help me out very much frusted tried all the stuffs. thankyou
 
    