Hello iam new to joomla創建模塊mod_testimonial。我這個已經把數據放到$rows = $db->loadObjectList();
從輔助文件,注意:未定義的偏移:第37行的default.php中的2注意:嘗試在第37行的default.php中獲取非對象的屬性文件未找到
和回聲後$行的數據是
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
)
)
我如default.php文件中我已經獲取從陣列作爲數據喜歡這個。
<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>
我的幫助文件是
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這裏所有的OKK,但如果我將會取消或後端unfeatured數據會引發錯誤這樣
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
我知道這是因爲沒有
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
)
我想給一個適當的循環,以便這個問題跳過,我不需要改變我的模板。
請幫我出去非常吃不消所有的東西。在你的幫助文件 三江源
檢查數組有值,則只能訪問其索引值 –
該是感謝,但如何獲得該數組在一個循環中,以便獲得連續性並顯示可用的數據。我已經嘗試了每個循環,但沒有變化,完全空白,請幫助我。 –
可能重複[參考 - 這是什麼錯誤在PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Sumurai8