这个是参照了别人的网站, 有点分层的意识.. 下面把代码粘出来保存. Index.php <?php Header ( "Content-type: text/vnd.wap.wml;charset=utf-8" ); Header ( "Cache-Control: no-cache, must-revalidate" ); Header ( "Pragma: no-cache" ); require_once 'operateDB.php'; //得到相关参数 if (empty ( $action )) { $action = $_POST [action]; if ($action == '') { $action = $_GET [action]; if ($action == '') { $action = 'loginform'; } } } $operatordb = new RegisteModule(); switch ($action) { case 'loginform' : include 'login.wml'; break; case 'login' : //设置相关参数 $result = $operatordb->ValidateUser($_POST[username],$_POST[userpass]); //print_r($result[ValidUserResult]); if($result->ValidUserResult == -1){ //登陆失败 $loginresult = "你输入的用户名或密码为误,请重新输入:"; include 'login.wml'; }else{ //登陆成功,在导入index页面前先得把要显示在index页面的信息 include 'beamToIndex.wml'; } break; case 'index' : //根据提供相关参数,获取全部分类及最新文章列表 $userid = $_GET[userid]; $categoryListResult = $operatordb->getCategoryAllList(); $newsTopArticle = $operatordb->getLastArtilces(); include 'index.wml'; break; case 'list' : //得到相关分类列表 $userid = $_GET[userid]; $categoryinfo = $operatordb->getCategoryInfo($_GET[categoryID]); $articleListByCategoryID = $operatordb->getArticleListByCategoryID($_GET[categoryID]); //得到分页信息 if(isset($_GET[page])){ $page = $_GET[page]; }else{ $page = 1; } $list_rows = 20; include 'list.wml'; break; case 'article' : $userid = $_GET[userid]; //得到文章详细信息和相关评论 $categorys = $operatordb->getCategoryIDByArticleID($_GET[articleID]); //$categoryinfo = $operatordb->getCategoryInfo($_GET[categoryID]); $articleInfo = $operatordb->getArticleByArticleID($_GET[articleID]); $commentListByArticleID = $operatordb->getCommentListByArticleID($_GET[articleID]); include 'article.wml'; break; case 'addComment' : if($_POST[userid]==''){ include 'beamToLogin.wml'; }else{ $userid = $_POST[userid]; $articleid = $_POST[articleid]; $comment = $_POST[comment]; $result = $operatordb->publicComments($articleid,$userid,$comment); include 'beamToArticle.wml'; } break; } ?> Index.wml <?php //require_once("page_list.php"); echo '<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head> <meta http-equiv="Cache-Control" content="max-age=7" forua="true"/> <meta http-equiv="content-type" content="text/vnd.wap.wml;charset=UTF-8"/> </head> <card id="main" title="TimeSheet"> <p><a href="index.php" mce_href="index.php">主页</a> 欢迎使用手机网</p>'; //读取数据库中的分类信息,放在一行中 echo '<p>'; for($i=0;$i<count($categoryListResult->GetCategoryListFromNewsArticlesResult->CategoryInfo);$i++){ echo '<a href="index.php?action=list&categoryID='.$categoryListResult->GetCategoryListFromNewsArticlesResult->CategoryInfo[$i]->CategoryID. '&userid='.$userid.'">' . $categoryListResult->GetCategoryListFromNewsArticlesResult->CategoryInfo[$i]->Name."</a> "; } echo '</p>'; //显示最新更新的二十条记录 for($i=0;$i<count($newsTopArticle->GetLastArtilcesListResult->sArticleInfo);$i++){ echo '<p><a href="index.php?action=article&articleID='. $newsTopArticle->GetLastArtilcesListResult->sArticleInfo[$i]->ArticleID .'&userid='.$userid.'">'. $newsTopArticle->GetLastArtilcesListResult->sArticleInfo[$i]->Title.'</a></p>'; } echo ' </card> </wml> '; ?> List.wml <?php require_once("page_list.php"); require_once("wap.inc.php"); echo '<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head> <meta http-equiv="Cache-Control" content="max-age=7" forua="true"/> <meta http-equiv="content-type" content="text/vnd.wap.wml;charset=UTF-8"/> </head> <card id="main" title="TimeSheet '.$categoryinfo->fields[1].'">'; echo '<p><a href="index.php?action=list&categoryID='.$categoryinfo->GetCategoryInfoResult->CategoryID.'&userid='.$_GET[userid].'">'.$categoryinfo->GetCategoryInfoResult->Name.'</a> <a href="index.php?action=index&userid='.$_GET[userid].'" mce_href="index.php?action=index&userid='.$_GET[userid].'">返回主页</a></p>'; //count($articleListByCategoryID->GetArtilcesListFromNewsArticlesResult->sArticleInfo) for($i=(($page-1)*$list_rows);$i<(($page*$list_rows)-1);$i++){ echo '<p><a href="index.php?action=article&categoryID='. $categoryinfo->GetCategoryInfoResult->CategoryID.'&articleID=' .$articleListByCategoryID->GetArtilcesListFromNewsArticlesResult->sArticleInfo[$i]->ArticleID .'&userid='.$_GET[userid].'">' .ConvertStr($articleListByCategoryID->GetArtilcesListFromNewsArticlesResult->sArticleInfo[$i]->Title).'</a></p>'; } $pages = new page_list(); $pages->display(count($articleListByCategoryID->GetArtilcesListFromNewsArticlesResult->sArticleInfo),$list_rows,$page, 'index.php?action=list&categoryID='.$categoryinfo->GetCategoryInfoResult->CategoryID .'&userid='.$_GET[userid]); echo ' </card> </wml> '; ?> Login.wml <?php echo '<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml"> <wml> <head> <meta http-equiv="Cache-Control" content="max-age=7" forua="true"/> <meta http-equiv="content-type" content="text/vnd.wap.wml;charset=UTF-8"/> </head> <card id="title" title="手机网登陆"> <p><font color="red">'.iconv("gbk","utf-8",$loginresult).'</font></p> <p>Username: <input type="text" name="username"/> <br/> Userpass: <input type="password" name="userpass"/> <br/> <anchor>提交 <go href="index.php" mce_href="index.php" method="post"> <postfield name="action" value="login"/> <postfield name="username" value="$(username)"/> <postfield name="userpass" value="$(userpass)"/> </go> </anchor> </p> </card> </wml> '; ?> Page_list.php <?php //require_once("wap.inc.php"); class page_list{ var $total_page; //总页面数 var $now_page; //当前页面 var $list_page; //前一页 var $next_page; //下一页 //计算总页面数,$rows 总记录数 , $list_rows 每页显示条数 function totalpage($rows,$list_rows){ $this->total_page = ceil($rows/$list_rows); $nums = $this->total_page; return $nums; } //计算当前页 function nowpage($page){ if(!isset($page) || $page <= 1){ $this->now_page = 1; }else{ $this->now_page = $page; } $pages = $this->now_page; return $pages; } //显示上一页,下一页 /* * rows 总记录 * list_rows 每页显示数目 * page 当前页 * url 跳转页面 */ function display($rows,$list_rows,$page,$url){ $page = $this->nowpage($page); $this->list_page = $page-1; $this->next_page = $page+1; if($this->nowpage($page)==1){ echo iconv("gbk","utf-8",'共'.$this->totalpage($rows,$list_rows).'页 | ' .'第1页 |' .'<a href="'.$url.'&page='.$this->next_page.'">'.'下一页 '.'</a>|'); }else if($this->nowpage($page)==$this->totalpage($rows,$list_rows)){ echo iconv("gbk","utf-8",'共'.$this->totalpage($rows,$list_rows).'页 | ' .'<a href="'.$url.'&page='.$this->list_page.'">'.'上一页 </a>|' .' 最后一页' ); }else{ echo iconv("gbk","utf-8",'共'.$this->totalpage($rows,$list_rows).'页' .'<a href="'.$url.'&page='.$this->list_page.'">'.'上一页 </a>| ' .'第'.$this->nowpage($page).'页 | ' .'<a href="'.$url.'&page='.$this->next_page.'">'.'下一页'.'</a> |'); } } } ?>