PHP的寫法:
$sql="select cht from `xx_oxford` where `eng`='{$eng}'";
$result=mysql_query($sql) or die(mysql_error());
list($cht)=mysql_fetch_row($result);
XOOPS的寫法:
$sql="select cht from ".$xoopsDB->prefix("oxford")." where `eng`='{$eng}'";
$result=$xoopsDB->queryF($sql) or redirect_header('index.php', 3, mysql_error());
list($cht)=$xoopsDB->fetchRow($result);
$xoopsTpl->assign('eng',$eng);
$xoopsTpl->assign('cht',$cht);
<{if $eng}>
<div class="hero-unit">
<h1><{$eng}></h1>
<p><{$cht}></p>
</div>
<{/if}>
$other="";
$i=1;
$sql="select eng,cht from ".$xoopsDB->prefix("oxford")." where `eng` like '{$eng}%'";
$result=$xoopsDB->queryF($sql) or redirect_header('index.php', 3, mysql_error());
while(list($eng,$cht)=$xoopsDB->fetchRow($result)){
$other[$i]['eng']=$eng;
$other[$i]['cht']=$cht;
$i++;
}
$xoopsTpl->assign('other',$other);
<ol>
<{foreach from=$other item=other}>
<li><a href="index.php?eng=<{$other.eng}>"><{$other.eng}></a> <{$other.cht}></li>
<{/foreach}>
</ol>