:::

7-3 上課範例:index.php

<?php

/*-----------引入檔案區--------------*/
include_once "header.php";
include_once "up_file.php";
$xoopsOption['template_main'] = "contact_index_tpl.html";
/*-----------function區--------------*/


//列出所有contact資料
function list_contact(){
	global $xoopsDB , $xoopsModule , $isAdmin;

	$jquery=get_jquery();

	//刪除確認的JS
	$main="
	$jquery
	
	<script type='text/javascript'>
  $(document).ready(function(){
  
    $.post('ajax.php' , function(data){
      $('#menu1').html(data);
      $.post('ajax.php' , {parent_gsn: $('#menu1').val()} , function(data){
        $('#menu2').html(data);
        contact_list();
      });
    });


    $('#menu1').change(function(){
      $.post('ajax.php' , {parent_gsn: $('#menu1').val()} , function(data){
        $('#menu2').html(data);
        contact_list();
      });
    });

    $('#menu2').change(function(){
      contact_list();
    });

  });
  
  //去抓該分類的通訊錄
  function contact_list(){
    $.post('ajax.php' , {gsn: $('#menu2').val()} , function(data){
      $('#contact_list').html(data);
    });
  }
  </script>
  
	<select id='menu1'></select>
	<select name='gsn' id='menu2'></select>
	
	<table summary='list_table' id='tbl' style='width:100%;'>
	<tr>
		<th>群組</th>
		<th>姓名</th>
		<th>電話</th>
		<th>信箱</th>
		<th>生日</th>
		<th>地址</th>
	</tr>

	<tbody id='contact_list'>
	$all_content
	</tbody>

	<tr>
		<td colspan=11 class='bar'>

		</td>
	</tr>
	</table>";

	//raised,corners,inset
	$main=div_3d("",$main,"corners");

	return $main;
}

//以流水號秀出某筆contact資料內容
function show_one_contact($sn=""){
	global $xoopsDB , $xoopsModule , $isAdmin;

	if(empty($sn)){
		return;
	}else{
		$sn=intval($sn);
	}

	$sql = "select * from `".$xoopsDB->prefix("contact")."` where `sn` = '{$sn}' ";
	$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'],3, mysql_error());
	$all=$xoopsDB->fetchArray($result);

	//以下會產生這些變數: $tel , $email , $name , $gsn , $sn , $birthday , $zip , $county , $city , $addr
	foreach($all as $k=>$v){
		$$k=$v;
	}


	$cate=get_contact_cate($gsn);
	
	//欄位 , 編號 , 是否縮圖 , 顯示模式 (空、filename、num) ,顯示描述,顯示下載次數
  //$photo_file=show_files('photo' , $sn);
  $photo_file=get_pic_file('photo' , $sn , 2 );
  $all_file=show_files('files' , $sn , ture , '' , true , true);
  
	$data="
	<table summary='list_table' id='tbl' style='width:100%;'>
	<tr><th nowrap>電話</th><td>{$tel}</td></tr>
	<tr><th nowrap>信箱</th><td>{$email}</td></tr>
	<tr><th nowrap>生日</th><td>{$birthday}</td></tr>
	<tr><th nowrap>地址</th><td>{$zip} {$county}{$city}{$addr}</td></tr>
	<tr><th nowrap>相片</th><td><img src='{$photo_file}'></td></tr>
	<tr><th nowrap>相關檔案</th><td>{$all_file}</td></tr>
	</table>";

	//raised,corners,inset
	$main=div_3d("{$cate['title']} / {$name}",$data,"corners");

	return $main;
}
/*-----------執行動作判斷區----------*/
$op=empty($_REQUEST['op'])?"":$_REQUEST['op'];
$sn=empty($_REQUEST['sn'])?"":intval($_REQUEST['sn']);
$gsn=empty($_REQUEST['gsn'])?"":intval($_REQUEST['gsn']);
$files_sn=empty($_REQUEST['files_sn'])?"":intval($_REQUEST['files_sn']);


switch($op){

	default:
  if(empty($sn)){
  	$main=list_contact();
  }else{
  	$main=show_one_contact($sn);
  }
	break;
}

/*-----------秀出結果區--------------*/
module_footer($main);
?>

:::

搜尋

QR Code 區塊

https%3A%2F%2Fmail.tad0616.cp27.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D769%26tbsn%3D26

書籍目錄

展開 | 闔起

線上使用者

344人線上 (139人在瀏覽線上書籍)

會員: 0

訪客: 344

更多…