tags:

views:

719

answers:

2

Hello all i want to create tabs according to data from MySQL database using php for instance count the number of groups if they are 5 create 5 tabs.How could i do that.

+1  A: 

You can generate JS from PHP just as easy as HTML.

If you are using inline JavaScript within your PHP file, you can just open up PHP and print out 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 pass .js files through PHP with this change in Apache for example.

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

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

Ólafur Waage
Ill be able to elaborate more in a few minutes.
Ólafur Waage
+1 for the AddType line
karim79
A: 

You could use the jQuery Tabs widget.

Each tab is made up of a list item and a div element, and it should be easy to write those from the content of your db in PHP.

santiiiii
I am sorry could you elaborate HOW?
Sarah