Search the Community
Showing results for tags 'tabbed'.
-
Hi, I am trying to create a tabbed image gallery using php and mysql . The following are my table structure. CREATE TABLE IF NOT EXISTS `gallery_category` ( `category_id` int(11) NOT NULL auto_increment, `category_name` text NOT NULL, PRIMARY KEY (`category_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; CREATE TABLE IF NOT EXISTS `photos` ( `photo_id` int(20) NOT NULL auto_increment, `photo_filename` varchar(25) NOT NULL, `photo_caption` text NOT NULL, `photo_category` bigint(20) NOT NULL, PRIMARY KEY (`photo_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=56 ; I am tring to create a tabbed gallery like this. <ul class="tabs"> <li><a href="#" rel="view1">gallery1</a></li> <li><a href="#" rel="view2">gallery2</a></li> </ul> <div class="tabcontents"> <div id="view1" class="tabcontent"> Gallery1 images goes here. </div> <div id="view2" class="tabcontent"> Gallery2 images goes here. </div> </div> Here is my code which i am trying to make this work. <ul class="tabs"> <?php $sql = "SELECT * FROM category ORDER BY category_id ASC"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $cid = $row['category_id']; $category_name = $row['category_name']; echo "<li><a href='?catid=".$cid."' rel='view".$cid."'>$category_name</a></li> "; } echo "</ul>"; ?> <div class="tabcontents"> <?php $sql = "SELECT * FROM category ORDER BY category_id ASC"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $catid = $row['category_id']; $category_name = $row['category_name']; $count = $row['COUNT(photo_id)']; echo"<div id='view".$catid."' class='tabcontent'>"; $catid = (int)($_GET['catid']); $sql = "SELECT * FROM gallery_photos WHERE photo_category = $catid ORDER BY photo_id DESC"; $query = mysql_query($sql); while($row = mysql_fetch_array($query)) { $pid = $row['photo_id']; $photo_caption = $row['photo_caption']; $photo_filename = $row['photo_filename']; echo "$photo_caption</br>"; echo "<img src='".$images_dir."/tb_".$row[photo_filename]."' border='0'"; } } ?> </div> </div> The category is displaying correctly (first <ul> </ul> part) but it content display part is not working. Can any one please help me with this.. Thanks, Sam.