Create jquery tabs according to data from database

I want to create tabs according to data from MySQL database using php, for example, count the number of groups if they 5 create 5 tabs. How can i do this.

0


a source to share


2 answers


You can generate JS from PHP as easy as HTML.

If you are using inline JavaScript in your PHP file, you can simply open PHP and print whatever you need.

<script type='text/javascript'>
    var foo = <?php echo $bar; ?>; 
    // this will create "var foo = 4;" if $bar = 4
</script>

      



If you are using .js files you can tell your HTTP server to serve .js files via PHP with this change to Apache eg.

AddType application/x-httpd-php .php .js

      

Apache will now transfer the .js files through PHP first. This can increase server load, and .js files are often cached more than php or html files.

+1


a source


You can use jQuery Tabs widget .



Each tab consists of a list element and a div element and should be easy to write from your db content in PHP.

0


a source







All Articles