//顯示所有結果
function list_all(){
global $xoopsDB,$xoopsUser,$xoopsModuleConfig;
$i=0;
$tbl=$xoopsDB->prefix('contact');
$sql="select * from $tbl";
//PageBar(資料數, 每頁顯示幾筆資料, 最多顯示幾個頁數選項);
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
$total=$xoopsDB->getRowsNum($result);
$navbar = new PageBar($total, $xoopsModuleConfig['show_num'], 10);
$mybar = $navbar->makeBar();
$bar= sprintf(_BP_TOOLBAR,$mybar['total'],$mybar['current'])."{$mybar['left']}{$mybar['center']}{$mybar['right']}";
$sql.=$mybar['sql'];
//分頁工具列為 $bar
$result=$xoopsDB->query($sql) or die(mysql_error());
$tool_title=($xoopsUser)?"<th>"._MD_CONTACT_FUNCTION."</th>":"";
$main="
".sprintf(_MD_CONTACT_TOTAL,$total,$mybar['total'])."
<table border=1 style='width:auto;'>
<tr><th>"._MD_CONTACT_PHOTO."</th><th>"._MD_CONTACT_NAME."</th><th>"._MD_CONTACT_SEX."</th><th>Email</th>$tool_title</tr>";
while($data=$xoopsDB->fetchArray($result)){
$sex=($data['sex']=="m")?_MD_CONTACT_MAN:_MD_CONTACT_WOMEN;
$color=($i % 2)?"white":"#f0f0f0";
$i++;
$photo=_DIR."/{$data['sn']}_s.png";
$show_photo=XOOPS_URL."/uploads/tad_contact/{$data['sn']}_s.png";
$pic=(file_exists($photo))?"<img src='$show_photo'>":"沒有圖";
$tool=($xoopsUser)?"<td>
<a href='index.php?op=modify&sn={$data['sn']}'>編輯</a> |
<a href='index.php?op=del&sn={$data['sn']}'>刪除</a>
</td>":"";
$main.= "
<tr bgcolor='$color'>
<td>$pic</td>
<td><a href='view.php?sn={$data['sn']}'>{$data['name']}</a></td>
<td>{$sex}</td>
<td>{$data['email']}</td>
$tool
</tr>";
}
$main.="</table>
<p>$bar</p>";
return $main;
}