:::

9-1 上課範例:add_class.php

<?php
require_once "header.php";

$op=isset($_REQUEST['op'])?$_REQUEST['op']:"";
$class_sn=isset($_REQUEST['class_sn'])?intval($_REQUEST['class_sn']):"";

$next_op=($class_sn)?"update":"insert";

//初始值設定
$data['seme'] = $data['class_name'] = $data['teacher'] = $data['passwd'] = $opt1 = $opt2 = $opt3 = $opt4 = $opt5 = $opt6 = $opt7 = $opt8 = $radio1 = $radio0 = "";

if($op=="edit"){
  //設定SQL語法
  $sql="select * from `tncomu_class` where class_sn='{$class_sn}'";

  //執行SQL語法
  $result=mysql_query($sql) or die("無法執行:".mysql_error());
 
  //擷取資料回來存到 $data
  $data=mysql_fetch_assoc($result);
 
  //還原下拉選單預設值
  $opt1=($data['subject']=="語言與文化")?"selected":"";
  $opt2=($data['subject']=="生命與健康")?"selected":"";
  $opt3=($data['subject']=="社會與生活")?"selected":"";
  $opt4=($data['subject']=="自然與環境")?"selected":"";
  $opt5=($data['subject']=="美學與藝術")?"selected":"";
  $opt6=($data['subject']=="資訊與傳播")?"selected":"";
  $opt7=($data['subject']=="台江分校")?"selected":"";
  $opt8=($data['subject']=="台江大廟興學")?"selected":"";

  $radio1=($data['access']=="1")?"checked":"";
  $radio0=($data['access']=="0")?"checked":"";
}


$main="
<form action='save_class.php' method='post'>
學年學期:<input type='text' name='seme' size='4' value='{$data['seme']}'><br>
所屬學程:<select name='subject' size=1>
  <option value='語言與文化' $opt1>語言與文化</option>
  <option value='生命與健康' $opt2>生命與健康</option>
  <option value='社會與生活' $opt3>社會與生活</option>
  <option value='自然與環境' $opt4>自然與環境</option>
  <option value='美學與藝術' $opt5>美學與藝術</option>
  <option value='資訊與傳播' $opt6>資訊與傳播</option>
  <option value='台江分校' $opt7>台江分校</option>
  <option value='台江大廟興學' $opt8>台江大廟興學</option>
</select>
<br>
班級名稱:<input type='text' name='class_name' size='30' value='{$data['class_name']}'><br>
講師名稱:<input type='text' name='teacher' size='10' value='{$data['teacher']}'><br>
管理密碼:<input type='text' name='passwd' size='10' value='{$data['passwd']}'><br>
是否開放:
<input type='radio' name='access' value='1' id='show' $radio1><label for='show'>開放</label>
<input type='radio' name='access' value='0' id='hide' $radio0><label for='hide'>隱藏</label>
<br>
<input type='hidden' name='op' value='{$next_op}'>
<input type='hidden' name='class_sn' value='{$class_sn}'>
<input type='submit' value='儲存'>
</form>";

$toolbar='
<li class="current_page_item"><a href="index.php">首頁</a></li>
<li><a href="add_class.php">班級管理</a></li>
<li><a href="add_class.php">發表文章</a></li>
';


theme("theme.html");
?>

:::

搜尋


書籍目錄

展開 | 闔起

線上使用者

9人線上 (6人在瀏覽線上書籍)

會員: 1

訪客: 8

wenyongfuo_goo,

更多…