phpbar.de logo

Mailinglisten-Archive

Select-Problem

Select-Problem

Patrick Bierans mysql_(at)_lists.phpcenter.de
Fri, 10 Aug 2001 11:39:43 +0100


> > id | parent | name
> > ---|--------|------
> > 1  |      0 | Name01
> > 2  |      0 | Name02
> > 3  |      0 | Name03
> > 4  |      1 | Name04
> > 5  |      1 | Name05
> > 6  |      4 | Name06

> while($mynode>=1 and $depth<=30){
> }

Hier ein Sniped, wie ich rekursiv einen Baum abgrase:

function childs($parent,$limit)
{
  run_sql("select * from ".TBL_C." where parent=$parent 
           order by name",$result);
  if (mysql_num_rows($result)>0)
  {
    echo "<ul class=\"grants\">";
    while ($row=mysql_fetch_array($result))
    {
      echo "<li>
            <a href=\"edit_category.php?id=$row[id]\">
              $row[name] ($row[id])
            </a>
            </li>\n";
      if ($limit>0) childs($row[id],$limit-1);
    }
    echo "</ul>\n";
  }
} // childs()


Stay cool, don't close the fridge

P.Bierans

---
!!NEU!!
Fragen und Antworten zu MySQL und dieser Liste unter
-->>  http://www.4t2.com/mysql 



php::bar PHP Wiki   -   Listenarchive