<?php
class myfunction{
 function str_to($str)
 { //字符转化 向数据库中插入或者更新用
$str=str_replace(" ","&nbsp;",$str) ;//把空格转换成字符串空格
$str=str_replace("<","&lt;",$str);//把HTML的输出标记正常输出
$str=str_replace(">","&gt;",$str);//把HTML的输出标记正常输出
$str=n12br($str);//把回车转换成HTML中的BR
return $str 
 }
 //由子模块的ID返回该子模块的主题数
  function son_module_idtonote_num($son_module_id){
   $aa =new mysql;
$aa->link("");
$query="select *from note_info where module_id='$son_module_id'and up_id='0'";
$rst=$aa->excu($query);
return mysql_num_rows($rst);
  
  }
  //由子模块的ID返回该子模块的帖子数
  function son_module_idtonote_num2($son_module_id){
  //由子模块的ID返回该子模块的主题数
  $aa=new mysql;
$aa->link("");
$query="selcet *from note_info where module_id='son_module_id'and up_id='0'";
$rst=$aa->excu($query);
$num=mysql_num_rows($rst);
while($note=mysql_fetch_array($rst,MYSQL_ASSOC)){
$query="select *from note_info where up_id='$note[id]' and module_id='0'";
$rst=$aa->excu($query);
$num+=mysql_num_rows($rst);
}
return $num;
 }
 //由子模块的ID返回该子模块的最新帖子
  function son_module_idtolast_note($son_module_id){
   //由子模块的ID输出该子模块的帖子
  $aa=new mysql;
$aa->link("");
$query="select *from note_info where module_id='$son_module_id' order by time desc limit 0,1";
$rst=$aa->excu($query);
$note=mysql_fetch_array($rst,MYSQL_ASSOC);
$query2="select *from note_info where id='$note[up_id]'";
$rst2=$aa->excu($query);
$note2=mysql_fetch_array($rst2,MYSQL-ASSOC);
echo $note2[title];
echo "<br>";
echo $note[time]."&nbsp;&nbsp;".$note[user_name];
 
   }
 //由子模块的ID返回该子模块的版主
 function son_module_idtouser_name($son_module_id){
  $aa=new mysql;
$aa->link("");
$query="select *from son_module_info where id='$son_module_id'"
$rst=$aa->excu($query);
$module=mysql_fetch_array($rst,MYSQL_ASSOC);
 if($module[user_name]==""){
  return "版主暂缺";
 }else{
  return $module[user_name];
 }
 }
 //输出所有模块的下拉列表(子模块有参数)
 function son_module_list($son_module_id){
  //输出所有的下拉列表
 $aa=new mysql;
 $aa->link("");
 $query="select * from father_module_info order by id";
 $rst=$aa->excu($query);
 echo"<select name=module_id>";
 while($father_module=mysql_fetch_array($rst,MYSQL_ASSOC)){
 echo "<option value=>".$father_module[module_name]."</option>";
 
 }
 $query="select *from son_module_info where father_module_id='$father_module[id]' order by id";
 $rst2=$aa->excu($query);
 while($son_module=mysql_fetch_array($rst2,MYSQL_ASSOC)){
 echo"<option value=".$son_module[id].">&nbsp;&nbsp;".$son_module[module_name]."</option>";
}
 
 }
 echo"</select>";
 //输出父模块的下拉列表
 function father_module_list($father_module_id){
   $aa=new mysql;
 $aa->link("");
 echo"<select name=father_module_id>";
 if($father_module_id==""){
  echo"<option selected>请选择...</option>";
 }
 else{
 $query="select *from father_module_info where id='$father_module_id'";
  $rst=$aa->excu($query);
father_module=mysql_fetch_array($rst,MYSQL_ASSOC);
 echo"<option value=".father_module[id].">".$father_module[module_name]."</option>";
 }
 $query="select *from father_module_info order by show_order";
 $rst=$aa->excu($query);
 while(father_module=mysql_fetch_array($rst,MYSQL_ASSOC)){
 
  echo"<option value=".father_module[id].">".$father_module[module_name]."</option>";
 }
 echo"</select>"
   }
 //由帖子的ID返回该帖子被浏览的次数 
  function note_idtotimes($note_id){
   $aa=new mysql;
$aa->link("");
$query="select *from note_info where id='$note_id'";
$rst=$aa->excu($query);
$note=mysql_fetch_array($rst,MYSQL_ASSOC);
return $note[times];
}
//由帖子的ID返回该帖子的标题
  function note_idtotitle($note_id){
        $aa=new mysql;
$aa->link("");
$query="select *from  note_info where id='$note_id'";
$rst=$aa->excu($query);
$note=mysql_fetch_array($rst,MYSQL_ASSOC);
return $note[title];
}

//由帖子的ID返回帖子的回复数
function note_idtonote_num($note_id){
$aa=new mysql;
$aa->link("");
$query="selcet * from note_info where up_id='$note_id'";
$rst=$aa->excu($query);
$num=mysql_num_rows($rst);
return $num+1;
}
//由帖子的ID输出帖子的最后回复时间
function note_idtolast_time($note_id){
$aa=new mysql;
$aa->link("");
$query="select *from note_info where up_id='$note_id' order by time desc limit 0,1";
$rst=$aa->excu($query);
$note=mysql_fetch_array($rst,MYSQL_ASSOC);
echo $note[time];
}
//由帖子的ID输出帖子的最后回复人
function note_idtolast_user_name($note_id){
$aa=new mysql;
$aa->link("");
$query="select *from note_info where up_id='$note_id' order by time desc limit 0,1";
$rst=$aa->excu($query);
$note=mysql_fetch_array($rst,MYSQL_ASSOC);
echo $note[user_name];
}

//由子模块的ID返回其父模块的名称function son_module_idtofather_name($son_module_id){
$aa=new mysql;
$aa->link("");
$query="select * from  son_module_info where id='son_module_id'";
$rst=$aa->exu($query);
$module=mysql_fetch_array($rst,MYSQL_ASSOC);
$query2="select *from father_module_info where id='$module[father_module_id]'";
$rst2=$aa->excu($query2);
$module2=mysql_fetch_array($rst2,MYSQL_ASSOC);
return $module2[module_name];
}//有子模块的ID返回本模块的名称
 function son_module_idtomodule_name($son_module_id){
  $aa=new mysql;
$aa->link("");
$query="select *from son_module_info where id='$son_module_id'";
$rst=$aa->excu($query);
$module=mysql_fetch_array($rst,MYSQL_ASSOC);
return $module[module_name];
  }//所有帖子的总数
 function note_total_num(){
  $aa=new mysql;
$aa->link("");
$query="select *from note_info";
$rst=$aa->excu($query);
return mysql_num_rows($rst);
 }
 
 //所有会员总数
 function user_total_num(){
  $aa=new mysql;
$aa->link("");
$query="select *from user_info";
$rst=$aa->excu($query);
return mysql_num_rows($rst);
  }//所有会员的总数
 function last_usename(){
 
 $aa=new mysql;
$aa->link("");
$query="select *from user_info order by id desc limit 0,1";
$rst=$aa->excu($query);
$user=mysql_fetch_array($rst,MYSQL_ASSOC);
return $user[user_name];
 }/////////////////////////////////////////////分页函数///////////////////////////////////////
 function page($query,$page_id,$add,$num_per_page){
 
        $bb=new mysql;
  global $query;
  $bb->link("");
  $page_id=$_GET[page_id];//接受page_id
  if($page_id==""){
   $page_id=1;
     }
  $rst=$bb->excu($query);
$num=mysql_num_rows($rst);
if($num==0){
echo "没有查到相关的记录或者相关的回复!<br>";
}
$page_num=ceil($num/$num_per_page);
for($i;$i<=$page_num;$i++){
echo "&nbsp;[<a href=?".$add."page_id=$i>".$i."</a>]";
}
$page_up=$page_id-1;
$page_down=$page_id+1;
 
 if($page_id==1){
  echo "<a href=?".$add."page_id=$page_down>下一页</a>&nbsp;&nbsp;
第".$page_id."页,共".$page_num."页";
 }else if($page_id>=$page_num-1){
  echo "<a href=?".$add."page_id=$page_up>上一页</a>&nbsp;&nbsp;第".$page_id."页,共".$page_num."页";
  }
         else{
  echo "<a href=?">$add."page_id=$page_up>上一页</a>&nbsp;&nbsp;<a href=?".$add."page_id=$page_down>下一页</a>&nbsp;&nbsp;
第".$page_id."页,共".$page_num."页";
  }
$page_jump=$num_per_page*($page_id-1);
$query=$query." limit $page_jump, $num_per_page";
 }

}
?>

解决方案 »

  1.   

    可以检查一下mysql类,还有$aa=new mysql;改为$aa=new mysql();加括号是个好的编程习惯
      

  2.   

    $rst=$aa->excu($query); 这断代码是正确的但是提示我有错误!
      

  3.   

    $query="select *from note_info where module_id='$son_module_id'and up_id='0'";
    這個語句不對吧$query="select *from note_info where module_id='".$son_module_id."' and up_id='0'";
      

  4.   

    $query="select * from note_info where module_id='$son_module_id'and up_id='0'";