I'd like to create some tabs with one active tab. Now the problem is I don't want to load all tabs at once, but only load the content of the active tab, the first tab by default and the content of the other tabs stored in a database.
...then to demonstrate the example create a PHP file, in the same folder as the file containing the above, with the following:
case 1: echo "this is the content for the <b>first</b> tab"; break;
case 2: echo "this is the content for the <b>second</b> tab"; break;
case 3: echo "this is the content for the <b>third</b> tab"; break;
case 4: echo "this is the content for the <b>fourth</b> tab"; break;
case 5: echo "this is the content for the <b>fifth</b> tab"; break;
To modify the PHP script to return DB content, you just need to replace my "echo" statements with mysql functions. I assume you know enough PHP to do this.
There is just one problem though. The tabs I'm about to use are quite large so they take a lot of the webpage.
Is there a possibility the URL structure changes when clicking another tab? The reason is people probably would like to point to a particular tab. When using the current code they always have to point to the default tab.
I guess so but you'd have to change my code to detect /pictures or whatever, then interpret that as a tab number.
But this would cause you problems because you want the URL to change on each click, without loading a new page. The only way to do this is with anchors (#). If you change the URL from /pictures to, say, /videos, you will change page and it will reload.
Why not use a system of named anchors instead, so not #1, #2 etc but #pictures, #videos etc.