Displaying contents of a tab

You have been answered in stackoverflow in the following way:

 <div id="tab-one" style="display: none">Tab1 info 1 content</div>
 <div id="tab-two" style="display: none">Tab1 info 2 content</div>
 <div id="tab-three" style="display: none">Tab1 info 3 content</div>

 <ul class="side bar tabs">
  <li class="one">Tab1 info 1</li>
  <li class="two">Tab1 info 2</li>
  <li class="three">Tab1 info 3</li>  
</ul>

You should run your query in while loop to get the result. define a $i = 1 before loop and increment it before closing while loop like $i++; Now change your html like this:

<div id="tab-<?php echo $i; ?>" style="display: none">code to get tab content</div>
<ul>
    <li class="<?php echo $i; ?>">Code to get tab title</li>
</ul>

If you have any confusion. write in comment box.