天空是蓝色的

做好软件为中国 #gcc -c helloworld.c -o helloworld.o //编译目标文件 #gcc helloworld.o -o helloworld //编译成可执行exe #helloworld //运行exe
数据加载中……
记一段代码[PHP]迭代读取数据库


<style>

input, select {
 font-size: 14px;
 color: #333333;
 padding-left:3px;
 background:#f6f6f6;
 border: #CCCCCC 1px solid;}
</style>
<?php
require_once dirname(__FILE__) ."/headers.php";

$i = 0;
  

function category($category_parent_timestamp){
   global $db;
   global $i;
   $result = $db->get("{category_parent_timestamp} == " . $category_parent_timestamp,null,"categories",false,"category_time","desc");
   sort($result);
  
   for($index=0;$index<count($result);$index++){          
     echo "<option>";
     for($x=0;$x<$i;$x++){
       echo "--";
      }      
     echo $result[$index]['category_title'];
     echo "&nbsp;";  
     $sub = $db->get("{category_parent_timestamp} == " .$result[$index]['category_timestamp'],null,"categories",false,"category_time","desc");
     if(count($sub)!=0){
       $i++;
       category($result[$index]['category_timestamp']);//迭代      
       $i--;
     }
     echo "</option>";
   }
   
}    
 
echo "<select>";
category("0"); 
echo"</select>";
?>

posted on 2006-06-23 00:09 bluesky 阅读(2937) 评论(2)  编辑  收藏 所属分类: PHP

评论

# re: 记一段代码[PHP]迭代读取数据库 2006-07-03 04:49 阿亮

这么多全都要么?还是什么?复制好后把代码放到哪了又要应该注意哪些问题的?
谢谢回答我的菜问题!
  回复  更多评论    

# re: 记一段代码[PHP]迭代读取数据库 2016-06-14 15:01 http://www.calvin-studio.fr

请赐教!非常感激!
  回复  更多评论    

只有注册用户登录后才能发表评论。


网站导航: