动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 用PHP3作树型目录

作者来源: 
阅读 数 671 人次 , 2006-3-29 4:10:00 


<? function style(){
 echo"<style>";
 echo"<!--";
 echo"a{font-size:9pt;color:blue}";
 echo"-->";
 echo"</style>";
 }
function getmessages($msgstart,$number,$type){
$conn=mysql_connect("localhost","207","");
mysql_select_db("test");
$sql="select*from message where fatheird=-1 and type=";
$sql=$sql.$type;
$sql=$sql."order by time desc limit ";
$sql=$sql.$msgstart;
$sql=$sql.",";
$sql=$sql.$number;
$result= mysql_query($sql,$conn);
if(!$result){
mysql_close($conn);
$msgs[0]=0;
return $msgs;
}
$count=0;
while ($obj=mysql_fetch_object($result)){
$count++;
$msgs[$count]=$obj;
}
$msgs[0]=$count;
mysql_close($conn);
return $msgs;
}
function insertmessage($msg){
if(!(($msg["title"])&&($msg["author"])&&($msg["time"]))){
return 0;
exit;
}
$conn=mysql_connect("localhost","207","");
mysql_select_db("test");
$sql="insert into message(title,body,author,fatherid,time,type)values('";
$sql=$sql.getsafestring($msg["title"]);
$sql=$sql."','";
$sql=$sql.getsafestring($msg["body"]);
$sql=$sql."','";
$sql=$sql.$msg["author"];
$sql=$sql."',";
$sql=$sql.$msg["fatherid"];
$sql=$sql.",'";
$sql=$sql.$msg["time"];
$sql=$sql."',";
$sql=$sql.$msg["type"];
$sql=$sql.")";
$result=mysql_query($sql,$conn);
mysql_close($conn);
return $result;
}
function getmessagebyfather($fatherid){
$conn=mysql_connect("localhost","207","");
mysql_select_db("test");
$sql="select*from message where fatherid=";
$sql=$sql.$fatherid;
$sql=$sql."order by time desc";
$result=mysql_query($sql,$conn);
if(!$result){
mysql_close($conn);
$msgs[0]=0;
return $msgs;
}
$count=0;
while($obj=mysql_fetch_object($result)){
$count++;
$msgs[$count]=$obj;
$msgs[$count]->child=getmessagebyfather($obj->id);
}
$msgs[0]=$count;
return $msgs;
}
$count=0;
while ($obj=mysql_fetch_object($result)){
$count++;
$msgs[$count]=$obj;
$msgs[$count]->child=getmessagebyfather($obj->id);
}
$msgs[0]=$count;
return $msgs;
}
function getmsgcount($type){
 $conn=mysql_connect("localhost","207","");
 mysql_select_db("test");
 $sql="select count(*)from message where fatherid=-1 and type=";
 $sql=$sql.$type;
 $result=mysql_query($sql,$conn);
 $count=mysql_result($result,0);
 mysql_colse($conn);
 return $count;
}
function getmessagebyid($id){
 $conn=mysql_connect("localhost","207","");
 mysql_select_db("test");
 $sql="select*from messgae where id=".$id;
 $result=mysql_query($sql,$conn);
 if(!$result)
return 0;
}
$obj=mysql_fetch_object($result);
mysql_colse($conn);
return $obj;
}
function getsafestring($string){
$string=str_replace("<","<",$string);
$string=str_replace(">",">",$string);
$string=str_replace("'","",$string);
$string=str_replace("\n","<br>",$string);
$string=str_replace(" ","",$string);
return $string
}

<?
require("/commonfuncs.php3");
require("home/websrc/userfuncs.php3");
function makeloginform(){
 echo"please login first<br>";
 echo"<form action+";
echo $globals["php_self"];

if(!$http_cookkie_vars["userid"]){
 if(!$username){
makeloginform();
exit;
 }
if(!$userinfo=getuserbyname($username))){
 echo "login name error!";
 exit;
}
 if($userinfo->password!=$password){
 echo "login password error!";
 exit;
}
$conn=dbconnect();
$sql="insert into useronline(uid,logintime,username)values(";
$sql=$sql.$userinfo->name;
$sql=$sql."')";
mysql_query($sql,$conn);
dbclose($conn);
if(!(setcookie("userid",$userinfo->id,"","/"))){
 echo"set cookie error!!";
 exit;
 }
 $strheader="location:".$php_self;
 header($strheader);
 exit;
 }
?>

 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:一个判断oicq是否在线的小程序
· 下一篇:用PHP实现动态产生XML文件以及从XML文件中抽取数据转化成HTML的小程序
· 在一个字符串中查找另一个字符串
· phpinfo()的小秘密
· ftp类(example.php)
· PHP出错界面
· WEB追捕PHP版源代码


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077