我工作一个Joomla模块和我写这篇文章的代码数据库连接,然后从数据库中提取数据,并在表打印出来
$db = JFactory::getDBO();
$query = $db->getQuery(true);
if($q == ""){
$query
->select(array('Stune_code,Stune_name,Stune_artist'))
->from('my_table')
->where('sub_cat_id = "4"')
->limit('$start, $per_page');
$query_pag_data = $db->loadObjectList();
$msg = "<table class='show-rslt'><tr>
<th class='tbl-header'>Song Title</th>
<th class='tbl-header'>Artist</th>
<th class='tbl-header'>Code</th>
</tr>";
while ($row = mysql_fetch_array($query_pag_data)) {
$msg .= "<tr>";
$msg .= "<td class='title'>" . htmlentities($row['Stune_name']) . "</td>";
$msg .= "<td class='title'>" . htmlentities($row['Stune_artist']) . "</td>";
$msg .= "<td class='title'>" . htmlentities($row['Stune_code']) . "</td>";
$msg .= "</tr>";
}
$msg .= "</table>";
$msg = "<div class='data'><ul>" . $msg . "</ul></div>"; // Content for Data
但它给了我这样的警告:“警告:mysql_fetch_array()预计参数1是资源,阵列中的C中给出:”
然后我调试和使用的print_r()它给我造成像
Array
(
[0] => stdClass Object
(
[Stune_code] => 501348
[Stune_name] => xxx
[Stune_artist] => abc
)
[1] => stdClass Object
(
[Stune_code] => 501351
[Stune_name] => xxx
[Stune_artist] => abc
)
[2] => stdClass Object
(
[Stune_code] => 5011727
[Stune_name] => xxx
[Stune_artist] => asd
)
...
...
我在哪里错了,我应该怎么办,以获得正确的结果