<a href='main.php?op=del_honor&honor_sn={$all['honor_sn']}'>刪除</a>
<a href='main.php?op=modify_honor&honor_sn={$all['honor_sn']}'>編輯</a>
$honor_sn = isset($_REQUEST['honor_sn']) ? intval($_REQUEST['honor_sn']) : "";
function del_honor($honor_sn=""){ global $xoopsDB; $sql="delete from ".$xoopsDB->prefix("tad_honor")." where `honor_sn`='{$honor_sn}'"; $xoopsDB->queryF($sql) or redirect_header('main.php', 3, mysql_error()); }
<script language='JavaScript' type='text/JavaScript'> function delete_data(sn){ var sure = window.confirm('確定要刪除此資料?'); if (!sure) return; location.href='main.php?op=delete_honor&honor_sn=' + sn; } </script>
<a href='javascript:delete_data({$all['honor_sn']})'>刪除</a>
<a href='main.php?op=modify_honor&honor_sn={$all['honor_sn']}'>編輯</a>
case "modify_honor": $main = honor_form($honor_sn); break;
//抓出原始資料 if($honor_sn){ $sql="select * from ".$xoopsDB->prefix("tad_honor")." where `honor_sn` = '$honor_sn'"; $result = $xoopsDB->query($sql) or redirect_header('main.php', 3, mysql_error()); $myts =& MyTextSanitizer::getInstance(); $all = $xoopsDB->fetchArray($result); }
$XoopsFormText =new XoopsFormText('得獎者', 'honor_student', 40 , 255, $all['honor_students']);
//設定op值 if($honor_sn){ $form->addElement(new XoopsFormHidden('op', 'update_honor')); $form->addElement(new XoopsFormHidden('honor_sn', $honor_sn)); }else{ $form->addElement(new XoopsFormHidden('op', 'insert_honor')); }
case "update_honor": update_honor($honor_sn); header("location:main.php"); break;
//更新榮譽榜資料庫 function update_honor($honor_sn=""){ global $xoopsDB; if(!$GLOBALS['xoopsSecurity']->check()){ $error=implode("<br />" , $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']); $sql="update ".$xoopsDB->prefix("tad_honor")." 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']}' where `honor_sn`='{$honor_sn}'"; $xoopsDB->queryF($sql) or redirect_header('main.php', 3, mysql_error()); }