8-3
上課範例:index.php
003 | include_once '../../mainfile.php' ; |
004 | include_once XOOPS_ROOT_PATH. "/header.php" ; |
015 | $sql = "select * from " . $xoopsDB ->prefix( "tad_note_cate" ). " where cate_enable='1' order by `cate_sort`" ; |
016 | $result = $xoopsDB ->query( $sql ) or redirect_header( 'cate.php' , 3, mysql_error()); |
017 | while ( $cate = $xoopsDB ->fetchArray( $result )){ |
018 | $option .= "<option value='{$cate['cate_sn']}'>{$cate['cate_title']}</option>" ; |
022 | $note_date = date ( "Y-m-d H:i:s" ); |
025 | <script type= 'text/javascript' src= 'class/ckeditor/ckeditor.js' ></script> |
026 | <script language= 'javascript' type= 'text/javascript' src= 'class/DatePicker/WdatePicker.js' ></script> |
028 | <form action= '{$_SERVER[' PHP_SELF ']}' method= 'post' > |
030 | <tr><th nowrap>所屬分類</th><td> |
031 | <select name= 'cate_sn' > |
032 | <option value= '0' >不分類</option> |
036 | <tr><th>文章標題</th><td><input type= 'text' name= 'note_title' size=40 value= '' ></td></tr> |
038 | <textarea name= 'note_content' cols=40 rows=6 class = 'ckeditor' id= 'ckeditor' ></textarea> |
039 | <script type= 'text/javascript' > |
040 | CKEDITOR.replace( 'ckeditor' , { skin : 'v2' , toolbar : 'MyToolbar' } ); |
043 | <tr><th>發布日期</th><td><input type= 'text' name= 'note_date' value= '$note_date' onClick=\"WdatePicker({skin: 'whyGreen' , dateFmt: 'yyyy-MM-dd HH:mm:ss' })\" class = 'Wdate' ></td></tr> |
044 | <tr><th>是否公開</th><td> |
045 | <input type= 'radio' name= 'note_public' value= '1' > 是 |
046 | <input type= 'radio' name= 'note_public' value= '0' > 否 |
048 | <tr><th>排序</th><td><input type= 'text' name= 'note_sort' size=2></td></tr> |
051 | <input type= 'hidden' name= 'op' value= 'save' > |
052 | <input type= 'submit' value= '儲存' > |
072 | global $xoopsDB , $xoopsUser ; |
074 | $uid = $xoopsUser ->uid(); |
076 | $sql = "insert into " . $xoopsDB ->prefix( "tad_notes" ). " (`cate_sn`, `note_title`, `note_content`, `note_date`, `note_public`, `note_count`, `uid`, `note_sort`) values('{$_POST['cate_sn']}' , '{$_POST['note_title']}' , '{$_POST['note_content']}' , '{$_POST['note_date']}' , '{$_POST['note_public']}' , '0' , '{$uid}' , '{$_POST['note_sort']}')" ; |
077 | $xoopsDB ->query( $sql ) or redirect_header( 'index.php' , 3, mysql_error()); |
082 | $main = "<a href='index.php?op=add_form'>新增記事</a>" ; |
087 | $op = empty ( $_REQUEST [ 'op' ])? "" : $_REQUEST [ 'op' ]; |
093 | header( "location:index.php" ); |
107 | include_once XOOPS_ROOT_PATH. '/footer.php' ; |