无限分类

?php$conn = mysql_connect(localhost,root,rootState of Qatar or die(数据库连接失入State of Qatar;
mysql_select_db(new,$conn);?分类:select name=fid?phpfunction mainfl(){
global $conn; $result=mysql_query(select id,fid,name from a where fid=0
order by id
,$connState of Qatar;//这里默许的fid=0,表示这是首先级。通过这些能够摸清全部fid=0的项,即具有的第一流主类
if ($myrow=mysql_fetch_array($result)) { do {? option value=?php echo
$myrow[id];??php echo
$myrow[name];?/option//$myrow[id]出口主类的ID为查询子类做筹算,$myrwo[name]主类名字?php
echo subfl($myrow[id],–卡塔尔国;?//调用子类函数subfl,使用–?php } while
($myrow=mysql_fetch_array($result卡塔尔卡塔尔国; }}//定义子级分类function
subfl($fid,$tag卡塔尔//$fid那是主类ID,$tag为总是符{global
$conn;$result1=mysql_query(select id,fid,name from a where fid=$fid
order by
id,$conn卡塔尔;//查询出fid=$fid的有着面,这里的$fid值为$myrow[id]if
($myrow1=mysql_fetch_array($result1)){ do {? option value=?php echo
$myrow1[id];??php echo $tag.$myrow1[name];?/option//输出子类?php
subfl($myrow1[id],-.$tag); } while
($myrow1=mysql_fetch_array($result1));}}echo mainfl();?/select

 
//Infiniti分类,首要观念是那样的,用fid
来记录该类的上一流ID,通过fid和id建设结构起上下级的关系。
<?php
$conn = mysql_connect(“localhost”,”root”,”root”State of Qatar  or
die(“数据库连接失入”卡塔尔(قطر‎;
  mysql_select_db(“new”,$conn);
?>
分类:<select name=”fid”>
<?php
function mainfl()
{
    global $conn;
  $result=mysql_query(“select id,fid,name from a where fid=0 order by
id
“,$conn卡塔尔(قطر‎;//这里暗许的fid=0,表示那是率先级。通过那个能够摸清全部fid=0的项,即具备的首先级主类
  if ($myrow=mysql_fetch_array($result))
  {
   do {
?>
    <option value=<?php echo $myrow[“id”];?>><?php echo
$myrow[“name”];?></option>//$myrow[“id”]输出主类的ID为查询子类做希图,$myrwo[“name”]主类名字
<?php echo subfl($myrow[“id”],”–“State of Qatar;?>//调用子类函数subfl,使用–

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图