Displaying related SQL queury results in jQuery accordian views

Displaying related SQL queury results in jQuery accordian views

I have the following working SQL query that returns rows with customer ids, names, and manager ids (man_id):

  1.     $result =   "SELECT * FROM customers WHERE man_id = :manid";
  2.     $stmt = $pdo->prepare($result);
  3.     $stmt->execute();
  4.     while($row = $stmt->fetch(PDO::FETCH_ASSOC))
  5.     {
  6.     $id1=$row['id'];
  7.     $name=$row['name'];
  8.     $manid=$row['man_id'];
  9.     ?>
  10.    
  11.     <div class="show">
  12.     <span class="name"><?php echo $id1;  ?></span>
  13.     <span class="name"><?php echo $name;  ?></span>
  14.     <span class="name"><?php echo $manid;  ?></span>
   
and I have a table with customer orders in it. The two tables are related via 'man_id' and the content is displayed with the following query:

  1.     $result_cat = "SELECT * FROM orders WHERE man_id = :manid";
  2.     $stmt = $pdo->prepare($result_cat);
  3.     $stmt->execute();
  4.     while($row = $stmt->fetch(PDO::FETCH_ASSOC))
  5.     {
  6.     $id2=$row['id'];
  7.     $cusname=$row['cust_name'];
  8.     $cusorder=$row['cust_order'];
  9.     ?>
  10.    
  11.     <div class="show">
  12.     <span class="name"><?php echo $id2;  ?></span>
  13.     <span class="name"><?php echo $cusname;  ?></span>
  14.     <span class="name"><?php echo $cusorder;  ?></span>

As I already said both of these are working as needed separate, but Id like to use the jQuery accordian widget (or similar, feel free to suggest alternatives) to display the orders per customer when a user clicks on a row in the customer data query.

Here is an image describing the operation:



original source: http://i7media.net/Data/Sites/1/blogdata/jquery-accordion-clip.png


Any thoughts on the best way to proceed are greatly appreciated.