<?php
include_once "../../mainfile.php";
$xoopsOption['template_main'] = "view_tpl.html";
define("_DIR",XOOPS_ROOT_PATH."/uploads/tad_contact");
$sn=(empty($_REQUEST['sn']))?"0":intval($_REQUEST['sn']);
$main=show_data($sn);
include_once XOOPS_ROOT_PATH."/header.php";
//echo $main;
$xoopsTpl->assign("content" , $main);
include_once XOOPS_ROOT_PATH.'/include/comment_view.php';
include_once XOOPS_ROOT_PATH.'/footer.php';
//顯示結果
function show_data($sn=""){
global $xoopsDB,$xoopsUser;
$tbl=$xoopsDB->prefix('contact');
$sql="select * from `$tbl` where `sn`='$sn'";
$result=$xoopsDB->query($sql) or die(mysql_error());
$data=mysql_fetch_array($result);
$sex=($data['sex']=="m")?"先生":"女士";
//$_POST['note']=stripslashes($_POST['note']);
if($xoopsUser){
$main= "<table border=1 style='width:auto;'>
<tr><th>姓名</th><td>{$data['name']}</td></tr>
<tr><th>性別</th><td>{$sex}</td></tr>
<tr><th>Email</th><td>{$data['email']}</td></tr>
<tr><th>電話</th><td>{$data['tel']}</td></tr>
<tr><th>手機</th><td>{$data['mtel']}</td></tr>
<tr><th>地址</th><td>
{$data['zip']}{$data['city']}{$data['town']}{$data['address']}
</td></tr>
<tr><th>服務單位</th><td>{$data['company']}</td></tr>
<tr><th>職稱</th><td>{$data['job']}</td></tr>
<tr><th>大頭照</th><td></td></tr>
<tr><th>其他說明</th><td>{$data['note']}</td></tr>
</table>";
}else{
$cols=explode(";",$data['show_data']);
$main= "<table border=1 style='width:auto;'>
<tr><th>姓名</th><td>{$data['name']}</td></tr>";
$main.=(in_array("Email",$cols))?"<tr><th>Email</th><td>{$data['email']}</td></tr>":"";
$main.=(in_array("性別",$cols))?"<tr><th>性別</th><td>{$sex}</td></tr>":"";
$main.=(in_array("電話",$cols))?"<tr><th>電話</th><td>{$data['tel']}</td></tr>":"";
$main.=(in_array("手機",$cols))?"<tr><th>手機</th><td>{$data['mtel']}</td></tr>":"";
$main.=(in_array("地址",$cols))?"<tr><th>地址</th><td>{$data['zip']}{$data['city']}{$data['town']}{$data['address']}</td></tr>":"";
$main.=(in_array("服務單位",$cols))?"<tr><th>服務單位</th><td>{$data['company']}</td></tr>":"";
$main.=(in_array("職稱",$cols))?"<tr><th>職稱</th><td>{$data['job']}</td></tr>":"";
$main.="
<tr><th>大頭照</th><td></td></tr>
<tr><th>其他說明</th><td>{$data['note']}</td></tr>
</table>";
}
return $main;
}
?>