Jump to content

magnetbox

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

magnetbox's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello all.. I've done some PHP in my day, but I'm no guru, and I've been stuck trying to get one function to work properly. What I want in a nutshell is an nested list with "Clusters" then SubClusters" listed under the appropriate cluster. I have a database full of rows with cluster / subcluster declaration. Here's the thing. A row may have a cluster only.. subcluster is totally optional. So, I need to be able to pull all the cluster and subcluster names, and nest the subclusters properly underneath their parent cluster. It's probably something stupid I'm just overlooking.... Here's what I have working, except for the fact that its showing duplicate clusters ( I know why I have dups, but this gives me all the info I want to display) echo'<ul>'; $result = mysql_query("SELECT cluster, subcluster FROM TABLE GROUP BY cluster, subcluster"); while ($row = mysql_fetch_array($result)) { if($row["subcluster"] != null) { echo '<li><a href="index.php?sort='.$row["cluster"].'">'.$row["cluster"].'</a></li>'; echo '<ul>'; echo '<li><a href="index.php?sort='.$row["subcluster"].'">- '.$row["subcluster"].'</a></li>'; echo '</ul>'; } else { echo '<li><a href="index.php?sort='.$row["cluster"].'">'.$row["cluster"].'</a></li>'; } } echo '</ul>';
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.