prefix("tad_honor"); $sql="select * from {$tbl} where honor_sn='{$honor_sn}'"; $result = $xoopsDB->query($sql) or die(mysql_error()); $all=$xoopsDB->fetchArray($result); $honor_year=$all['honor_year']; $honor_date=$all['honor_date']; $honor_students=$all['honor_students']; $honor_descript=$all['honor_descript']; $honor_teachers=$all['honor_teachers']; $honor_note=$all['honor_note']; $uid=$all['uid']; $op="update_honor"; }else{ //預設值 $honor_year="103"; $honor_date=""; $honor_students=""; $honor_descript=""; $honor_teachers=""; $honor_note=""; $uid=$xoopsUser->uid(); $op="add_honor"; } //引入XOOPS表單 include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php"); //建立XOOPS表單 $form = new XoopsThemeForm('榮譽榜編輯表單', 'honor_form', 'main.php', 'post', true , '榮譽榜編輯表單'); //在表單中,加入一個文字輸入框 $form->addElement(new XoopsFormText('學年度', 'honor_year', 3 , 3 , $honor_year) , true); //在表單中,加入一個日期輸入框 $form->addElement(new XoopsFormTextDateSelect('得獎日期', 'honor_date', 20 , $honor_date) , true); //在表單中,加入一個文字輸入框 $form_honor_students = new XoopsFormText('得獎者', 'honor_students' , 255 , 255 , $honor_students); $form_honor_students->setExtra("class='span12' placeholder='請填入得獎者'"); $form->addElement($form_honor_students , true); //在表單中,加入一個大量文字輸入框 $form_honor_descript = new XoopsFormTextArea('得獎事項', 'honor_descript' , $honor_descript , 5 , 255); $form_honor_descript->setExtra("class='span12' placeholder='請填入得獎事項'"); $form->addElement($form_honor_descript , true); //在表單中,加入一個文字輸入框 $form->addElement(new XoopsFormText('指導老師', 'honor_teachers', 255 , 255 , $honor_teachers) , false); //在表單中,加入一個大量文字輸入框 $form_honor_note = new XoopsFormTextArea('備註', 'honor_note' , $honor_note , 5 , 255); $form_honor_note->setExtra("class='span12' placeholder='請填入備註'"); $form->addElement($form_honor_note , false); //在表單中,加入一個隱藏表單 $form->addElement(new XoopsFormHidden('uid' , $uid)); $form->addElement(new XoopsFormHidden('op' , $op)); $form->addElement(new XoopsFormHidden('honor_sn' , $honor_sn)); $Tray1=new XoopsFormElementTray('', ' ', ''); $Tray1->addElement(new XoopsFormButton('', '', '送出', 'submit')); $Tray1->addElement(new XoopsFormButton('', '', '清除', 'reset')); $form->addElement($Tray1); //將表單物件轉換為表單語法 $f=$form->render(); //將表單語法套用到樣板中 $xoopsTpl->assign('honor_form' , $f); $xoopsTpl->assign('now_op' , 'honor_form'); $xoopsTpl->assign('temp_title' , '榮譽榜編輯表單'); } //新增事件到資料庫 function add_honor(){ global $xoopsDB; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("" , $GLOBALS['xoopsSecurity']->getErrors()); redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $_POST['honor_year']=$myts->addSlashes($_POST['honor_year']); $_POST['honor_date']=$myts->addSlashes($_POST['honor_date']); $_POST['honor_students']=$myts->addSlashes($_POST['honor_students']); $_POST['honor_descript']=$myts->addSlashes($_POST['honor_descript']); $_POST['honor_teachers']=$myts->addSlashes($_POST['honor_teachers']); $_POST['honor_note']=$myts->addSlashes($_POST['honor_note']); $tbl=$xoopsDB->prefix("tad_honor"); $sql="INSERT INTO `{$tbl}` (`honor_year`, `honor_date`, `honor_students`, `honor_descript`, `honor_teachers`, `honor_note`, `uid`) VALUES ( '{$_POST['honor_year']}' , '{$_POST['honor_date']}' , '{$_POST['honor_students']}' , '{$_POST['honor_descript']}' , '{$_POST['honor_teachers']}' , '{$_POST['honor_note']}' , '{$_POST['uid']}')"; $xoopsDB->query($sql) or die(mysql_error()); } //更新事件到資料庫 function update_honor($honor_sn=""){ global $xoopsDB; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("" , $GLOBALS['xoopsSecurity']->getErrors()); redirect_header($_SERVER['PHP_SELF'],3, $error); } $myts =& MyTextSanitizer::getInstance(); $_POST['honor_year']=$myts->addSlashes($_POST['honor_year']); $_POST['honor_date']=$myts->addSlashes($_POST['honor_date']); $_POST['honor_students']=$myts->addSlashes($_POST['honor_students']); $_POST['honor_descript']=$myts->addSlashes($_POST['honor_descript']); $_POST['honor_teachers']=$myts->addSlashes($_POST['honor_teachers']); $_POST['honor_note']=$myts->addSlashes($_POST['honor_note']); $tbl=$xoopsDB->prefix("tad_honor"); $sql="update `{$tbl}` set `honor_year`='{$_POST['honor_year']}' , `honor_date`='{$_POST['honor_date']}', `honor_students`='{$_POST['honor_students']}', `honor_descript`='{$_POST['honor_descript']}', `honor_teachers`='{$_POST['honor_teachers']}', `honor_note`='{$_POST['honor_note']}' where honor_sn='$honor_sn'"; $xoopsDB->queryF($sql) or die(mysql_error()); } //刪除榮譽榜事件 function delete_honor($honor_sn=""){ global $xoopsDB; $tbl=$xoopsDB->prefix("tad_honor"); $sql="delete from `{$tbl}` where honor_sn='$honor_sn'"; $xoopsDB->queryF($sql) or die(mysql_error()); } /*------------------ 檔尾(輸出內容到樣板) ------------------*/ include "footer.php"; //XOOPS檔尾 ?> ```
進階搜尋
41人線上 (11人在瀏覽線上書籍)
會員: 0
訪客: 41