I'm new to coding with php and using MySQL. I am having trouble to display a list of categories by their ID so that each category is displayed individually as a heading. Instead I got it to display a category name but its only echoing out a category name twice that's the same. Here is my code...

```
$sql= "SELECT * FROM categories ";
$query = mysql_query($sql); 

while($row = mysql_fetch_array($query))
 {
     $id=$row['id'];
     $cat_name=$row['cat_name'];

 }
 ?>

<ul class="nav nav-list">

 <li class="nav-header"><?php echo $cat_name;?></li>
 <li class="nav-header"><?php echo $cat_name;?></li>
</ul>

```