Count number of rows to generate a certain number of tabs
<p>So I have something which allows the user to add tabs and take away tabs... however how would I go about generating the default number of tabs based on data from my sql database. For example if they were 4 rows with the same id in the id filed, it would generate 4 tabs as there is 4 rows with the same id.</p>

<p>here is the tab thing I found.</p>

<pre><code>&lt;script&gt;
$(function() {

var total_tabs = 0;



    // initialize first tab

    total_tabs++;

    addtab(total_tabs);



    $("#addtab, #litab").click(function() {

    total_tabs++;

    $("#tabcontent p").hide();

    addtab(total_tabs);

    return false;

    });


    function addtab(count) {

    var closetab = '&lt;a href="" id="close'+count+'" class="close"&gt;&amp;times;&lt;/a&gt;';

       $("#tabul").append('&lt;li id="t'+count+'" class="ntabs"&gt;Session      '+count+'&amp;nbsp;&amp;nbsp;'+closetab+'&lt;/li&gt;');

       $("#tabcontent").append('&lt;p id="c'+count+'"&gt;Tab Content '+count+'&lt;/p&gt;');


       $("#tabul li").removeClass("ctab");

       $("#t"+count).addClass("ctab");



       $("#t"+count).bind("click", function() {

        $("#tabul li").removeClass("ctab");

        $("#t"+count).addClass("ctab");

        $("#tabcontent p").hide();

        $("#c"+count).fadeIn('slow');

       });



       $("#close"+count).bind("click", function() {

        // activate the previous tab

        $("#tabul li").removeClass("ctab");

        $("#tabcontent p").hide();
        $(this).parent().prev().addClass("ctab");

        $("#c"+count).prev().fadeIn('slow');



        $(this).parent().remove();

        $("#c"+count).remove();

        return false;

     });

      }

  });

  &lt;/script&gt;


 &lt;ul id="tabul"&gt;
 &lt;li id="litab" class="ntabs add"&gt;&lt;a href="" id="addtab"&gt;Add tab + &lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
</code></pre>

<p>Thanks James</p>
