新聞列表"; $error_msg=$main=""; /*----流程控制----*/ switch ($op) { case 'clear': session_destroy(); header("location:post.php"); break; case 'passwd_error': $main=news_form($sn); $error_msg=error_msg("密碼錯誤!!請檢查密碼是否正確!"); break; case 'db_error': $error_msg=error_msg("資料庫連線錯誤!!請檢查資料庫帳號、密碼是否正確!"); break; case 'save': save_news(); header("location:index.php"); exit; break; case 'update': save_news($sn); header("location:index.php?op=view&sn={$sn}"); exit; break; case 'modify': $main=news_form($sn); break; default: $main=news_form(); break; } /*----輸出----*/ show_page('post_tpl'); /*----所有函數----*/ //新聞編輯表單 function news_form($sn=""){ link_db(); if($sn){ //讀取eznews資料表所有欄位,並指定某一筆特定資料 $sql="select * from eznews where sn='$sn'"; //傳回值存到 $result 以供抓取資料用 $result=mysql_query($sql) or die("{$sql}".mysql_error()); $news=mysql_fetch_assoc($result); // foreach ($news as $k => $v) { // $$k=$v; // } $news_title=$news['news_title']; $news_content=$news['news_content']; $ip=$news['ip']; $author=$news['author']; $post_time=$news['post_time']; $def_cate_sn=$news['cate_sn']; $next_op="update"; //抓附檔 $sql="select * from eznews_files where sn={$sn}"; $result=mysql_query($sql) or die("{$sql}".mysql_error()); $files_list="請選擇欲刪除檔案:"; while($file=mysql_fetch_assoc($result)){ $files_list.=" {$file['file_name']} "; } }else{ $news_title=isset($_SESSION['news_title'])?$_SESSION['news_title']:""; $news_content=isset($_SESSION['news_content'])?$_SESSION['news_content']:""; $ip=$_SERVER['REMOTE_ADDR']; $author=isset($_SESSION['author'])?$_SESSION['author']:""; $post_time=isset($_SESSION['post_time'])?$_SESSION['post_time']:date("Y-m-d H:i:s"); $def_cate_sn=""; $news['status']=""; $next_op="save"; } //製作分類的下拉選項 $sql="select * from eznews_cate"; $result=mysql_query($sql) or die($sql.''.mysql_error()); $cate_options=""; while(list($cate_sn , $cate_title)=mysql_fetch_row($result)){ $selected=($cate_sn==$def_cate_sn)?"selected":""; $cate_options.="$cate_title"; } $checked_default=(isset($news['status']) and $news['status']=="")?"checked":""; $checked_top=(isset($news['status']) and $news['status']=="置頂")?"checked":""; $checked_important=(isset($news['status']) and $news['status']=="高亮")?"checked":""; $main=<<
進階搜尋
127人線上 (44人在瀏覽線上書籍)
會員: 0
訪客: 127