c_all($db_host,$db_user,$db_psw,$db_table);
//require(include/sess.php);
$my = new mydb();
$my->c_all($db_host,$db_user,$db_psw,$db_table);
require(include/header.php);
require(config/smarty_freeday.php);
$smarty = new smarty_freeday;
$query = select count(*) from fd_music order by mc_id desc;
$res =$my->query($query);
$total = $my->fetch_arr($res);
$total = $total[0];
$queryn = select * from fd_music order by mc_id desc;
$result =$my->query($queryn);
$i = 0;
$j = 1;
$musicarr = array();
if ($result)
{
while ($n = $my->fetch_arr($result))
{
$i ++;
$musicitem[$j-1][name] = $n[mc_name];
$musicitem[$j-1][songer] = $n[mc_songer];
$musicitem[$j-1][url] = $n[mc_url];
$j ++;
if($i==$total && $j%5!=0)
{
$musicarr[] = $musicitem;
}
if($j%5 == 0)
{
$musicarr[] = $musicitem;
$musicitem = ;
$j = 1;
}
}
}
else
{
echo 连接数据库出错!
;
}
$smarty->assign('total',$total);
$smarty->assign('musicarr',$musicarr);
$my->close();
$smarty->display('music.htm');
require(include/footer.php);
exit();
?>
music.htm
table class=toutm width=768 align=center cellpadding=0 cellspacing=0>
tr>
td height=25 class=tdbc>总共有歌曲font color=#ff0000>$total}>font>首
td>
tr>
tr>
td width=768 class=line>
td>
tr>
tr>
td>
table>
tr>
td>
table>
section name=secf loop=$musicarr}>
tr>
section name=secs loop=$musicarr[secf]}>
td>
img src=images/11.gif width=12>a title= onclick=window.open(this.href,'','top=0,left=0,width=550,height=370,scrollbars=yes,resizable=no');return false; href=http://freeday.512j.com/old/wj/sp.php?path= target=_blank>$musicarr[secf][secs].name}>《$musicarr[secf][secs].songer}>》a>
td>
section}>
tr>
section}>
table>
td>
tr>
table>
td>
tr>
tr>
td width=768 class=line>td>
tr>
table>
更简单的方法:
代码:
table border=1 width=599 cellpadding=0 cellspacing=0 align=center>
tr>
section name=mydata loop=$news}>
td width=69% align=center>
a href=#?id=>$news[mydata].news_title}>a>
td>
$smarty.section.mydata.rownum is div by 3}>
tr>
tr>
section}>
tr>
table>