3-2
上課範例:index.php
004 | include_once "header.php" ; |
005 | $xoopsOption [ 'template_main' ] = "contact_index_tpl.html" ; |
010 | function list_contact(){ |
011 | global $xoopsDB , $xoopsModule , $isAdmin ; |
013 | $sql = "select * from `" . $xoopsDB ->prefix( "contact" ). "` " ; |
014 | $result = $xoopsDB ->query( $sql ) or redirect_header( $_SERVER [ 'PHP_SELF' ],3, mysql_error()); |
018 | while ( $all = $xoopsDB ->fetchArray( $result )){ |
020 | foreach ( $all as $k => $v ){ |
025 | $cate =get_contact_cate_all(); |
029 | <td>{ $cate [ $gsn ][ 'title' ]}</td> |
030 | <td><a href= 'index.php?sn=$sn' >{ $name }</a></td> |
034 | <td>{ $zip } { $county }{ $city }{ $addr }</td> |
039 | $jquery =get_jquery(); |
045 | <script type= 'text/javascript' > |
046 | $(document).ready( function (){ |
048 | $.post( 'ajax.php' , function (data){ |
049 | $( '#menu1' ).html(data); |
050 | $.post( 'ajax.php' , {parent_gsn: $( '#menu1' ).val()} , function (data){ |
051 | $( '#menu2' ).html(data); |
056 | $( '#menu1' ).change( function (){ |
057 | $.post( 'ajax.php' , {parent_gsn: $( '#menu1' ).val()} , function (data){ |
058 | $( '#menu2' ).html(data); |
066 | <select id= 'menu1' ></select> |
067 | <select name= 'gsn' id= 'menu2' ></select> |
069 | <table summary= 'list_table' id= 'tbl' style= 'width:100%;' > |
084 | <td colspan=11 class = 'bar' > |
091 | $main =div_3d( "" , $main , "corners" ); |
097 | function show_one_contact( $sn = "" ){ |
098 | global $xoopsDB , $xoopsModule , $isAdmin ; |
106 | $sql = "select * from `" . $xoopsDB ->prefix( "contact" ). "` where `sn` = '{$sn}' " ; |
107 | $result = $xoopsDB ->query( $sql ) or redirect_header( $_SERVER [ 'PHP_SELF' ],3, mysql_error()); |
108 | $all = $xoopsDB ->fetchArray( $result ); |
111 | foreach ( $all as $k => $v ){ |
116 | $cate =get_contact_cate( $gsn ); |
119 | <table summary= 'list_table' id= 'tbl' style= 'width:100%;' > |
120 | <tr><th nowrap>電話</th><td>{ $tel }</td></tr> |
121 | <tr><th nowrap>信箱</th><td>{ $email }</td></tr> |
122 | <tr><th nowrap>生日</th><td>{ $birthday }</td></tr> |
123 | <tr><th nowrap>地址</th><td>{ $zip } { $county }{ $city }{ $addr }</td></tr> |
127 | $main =div_3d( "{$cate['title']} / {$name}" , $data , "corners" ); |
132 | $op = empty ( $_REQUEST [ 'op' ])? "" : $_REQUEST [ 'op' ]; |
133 | $sn = empty ( $_REQUEST [ 'sn' ])? "" : intval ( $_REQUEST [ 'sn' ]); |
134 | $gsn = empty ( $_REQUEST [ 'gsn' ])? "" : intval ( $_REQUEST [ 'gsn' ]); |
135 | $files_sn = empty ( $_REQUEST [ 'files_sn' ])? "" : intval ( $_REQUEST [ 'files_sn' ]); |
142 | $main =list_contact(); |
144 | $main =show_one_contact( $sn ); |