开发者

Querying MySQL tables and displaying results in tabbed-panes

开发者 https://www.devze.com 2023-02-12 05:38 出处:网络
I have an PHP array. I have to loop over it to query 3 MySQL tables. The attributes of开发者_Python百科 all the tables are the same, just the table names are different.

I have an PHP array. I have to loop over it to query 3 MySQL tables. The attributes of开发者_Python百科 all the tables are the same, just the table names are different.

Once I get the results I have to display it in tabbed-panes. I will have 3 tabbed-panes. When I click on the tab, respective results should populate the table.

How can I go about retrieving and displaying this?


Take a look at the Tabs widget in jQuery UI: http://jqueryui.com/demos/tabs/

There are several approaches for populating the tabs with data. The easiest one is to use PHP to to generate HTML similar to this:

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">Tab 1</a></li>
        <li><a href="#tabs-2">Tab 2</a></li>
        <li><a href="#tabs-3">Tab 3</a></li>
    </ul>
    <div id="tabs-1">
        <p>Tab 1 content</p>
    </div>
    <div id="tabs-2">
        <p>Tab 2 content</p>
    </div>
    <div id="tabs-3">
        <p>Tab 3 content</p>
    </div>
</div>

Replace data inside the "tabs-x" div tags with output from your database query.

Javascript for initializing the tabs:

$(function() {
    $("#tabs").tabs();
});

If you need the tabs to populate when clicked, take a look at the AJAX-option: http://jqueryui.com/demos/tabs/#ajax

0

精彩评论

暂无评论...
验证码 换一张
取 消