Smarty: Some can be simpler

Source: Internet
Author: User
<?php
/**
*
* @author Whirlwind, <bighuang at 126 dot com>
* @copyright Copyright (c) Leisure website, 2004-2005
* @since ~
*/
/*+++++++++++++++++++++++++
* Copyright (c) 2004, leisure website
* All rights reserved
*
* System Name: Leisure Music
* File name: diary.php
* File identification: See Configuration management Plan
function
Summary
*
* Current Version: 1.0
* Author: Whirlwind
* Author Homepage: http://freeday.512j.com
* Author Email: bighuang@126.com
* Author qq:121173553
* Date of Completion: April 3, 2005
*
* Replacement Version: 1.0
* Original Author: whirlwind
* Date of Completion: April 3, 2005
+++++++++++++++++++++++++*/
Include "config/config.php" ;
Include "config/dbclass.php" ;
Include "include/freedaycodechange.php" ;
$my = new MyDB ();
$my->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 ' <TR><TD align=center > Connection Database Error! </td></tr> " ;
}


$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= class= "Tdbc" > A total of songs <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 >
<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=<{$musicArr [secf][secs].url}>" 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> a simpler approach:
 Code: 
     
<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_id}>"><{$news[MyData].News_title}></a>
</TD>
<{if$smarty. Section.MyData.RowNum is div by 3}>
</TR>
<TR>
<{/if}>
<{/ Section}>
</TR>
</Table>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.