I'm trying to make a tab for my page, where each tab shows a different field of a mysql table row. I'd like to switch contents in the tab. Every row has a different id, and I would like to make a tabbed design. The data should be chosen by the id of the table. The tab works fine if i use just a simple text in the echo part, but I can't fetch the data from my database. I tried this code, but it doesn't work.
<?php
if (isset($data[0]) && is_numeric($data[0]) ) {
$content = mysql_fetch_assoc ( mysql_query( "select id,tab_content_one,tab_content_two,tab_content_three,tab_content_four,tab_content_five from db_name where id = $data[0];") );
} else {
$content = mysql_fetch_assoc ( mysql_query( "select id,tab_content_one,tab_content_two,tab_content_three,tab_content_four,tab_content_five from db_name order by id asc limit 1;") );
}
switch($_GET['tabNum']) {
case 1: echo strip_tags($content['tab_content_one']); break;
case 2: echo strip_tags($content['tab_content_two']); break;
case 3: echo strip_tags($content['tab_content_three']); break;
case 4: echo strip_tags($content['tab_content_four']); break;
case 5: echo strip_tags($content['tab_content_five']); break;
}
?>
I don't know what's wrong with my code. Do you have any idea?