面对根据jquery在多个类别上集成的问题

I am using accordion jquery on the following PHP while loop but it is not working properly. When I am opening any category window it closes other windows automatically. I need to apply accordion jquery on each category exclusively that I am creating from back end. I will appreciate your help.

$cates=mysql_query('select * from categories');
   while($gets=mysql_fetch_array($cates))
   {
   $title=$gets['title'];
   $id=$gets['id'];
   echo'<li ><a class="account nav-user" href="categories.php?cid='.$id.'" style="text-decoration:none;color:orange;">'.$title.'</a> //Categories list
<ul>      
<ul>';

    $ads=mysql_query('select * from items where cid="'.$id.'" order by id desc limit 5');
    while($items=mysql_fetch_array($ads)){
    $item=$items['product_name'];
    $adid=$items['id'];

               echo '<li><a style="text-decoration:none;color:grey;" href="addetail.php?id='.$adid.'">'.$item.'</a></li>'; //Product list

}             
    echo '</ul>';
          echo '</li> </ul>';
    }