:::

5-3 /index.php

<?php
/*-----------引入檔案區--------------*/
include_once "header.php";
$xoopsOption['template_main'] = set_bootstrap("tad_ebook_index.html");
include_once XOOPS_ROOT_PATH."/header.php";

/*-----------function區--------------*/

//顯示預設頁面內容
function show_page($page_sn=""){
  global $xoopsTpl ,$xoopsDB;

  $tbl=$xoopsDB->prefix('tad_ebook_page');
  $sql="select * from `{$tbl}` where `page_sn` = '{$page_sn}'";
  $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error());
  $page=$xoopsDB->fetchArray($result);
  $xoopsTpl->assign('page',$page);
  $xoopsTpl->assign('op', 'show_page');
}

//顯示所有期數列表
function show_all(){
  global $xoopsTpl ,$xoopsDB;
  $today=date("Y-m-d");
  $tbl=$xoopsDB->prefix('tad_ebook');
  $sql="select * from `{$tbl}` where `ebook_publish_date` <= '{$today}'";

  $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error());

  while($ebook=$xoopsDB->fetchArray($result)){
    $all_ebook[]=$ebook;
  }
  $xoopsTpl->assign('all_ebook',$all_ebook);
  $xoopsTpl->assign('op', 'show_all');
}


//顯示某期文章列表
function show_ebook($ebook_sn=""){
  global $xoopsTpl ,$xoopsDB;

  $tbl=$xoopsDB->prefix('tad_ebook_page');
  $sql="select * from `{$tbl}` where `ebook_sn` = '{$ebook_sn}'";

  $result=$xoopsDB->query($sql) or redirect_header("index.php",3, mysql_error());

  while($page=$xoopsDB->fetchArray($result)){
    $all_page[]=$page;
  }
  $xoopsTpl->assign('all_page',$all_page);
  $xoopsTpl->assign('op', 'show_ebook');
}


/*-----------執行動作判斷區----------*/
$op=empty($_REQUEST['op'])?"":$_REQUEST['op'];
$page_sn=empty($_REQUEST['page_sn'])?"":intval($_REQUEST['page_sn']);
$ebook_sn=empty($_REQUEST['ebook_sn'])?"":intval($_REQUEST['ebook_sn']);

switch($op){

  // case "xxx":
  // xxx();
  // header("location:{$_SERVER['PHP_SELF']}");

  default:
  if($page_sn){
    show_page($page_sn);
  }elseif($ebook_sn){
    show_ebook($ebook_sn);
  }else{
    show_all();
  }

  break;
}

/*-----------秀出結果區--------------*/
$xoopsTpl->assign( "toolbar" , toolbar_bootstrap($interface_menu)) ;
include_once XOOPS_ROOT_PATH.'/footer.php';
?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D37%26tbdsn%3D1142

書籍目錄

展開 | 闔起

線上使用者

69人線上 (15人在瀏覽線上書籍)

會員: 0

訪客: 69

更多…