CREATE TABLE `album` ( `AlbumID` int(4) unsigned zerofill NOT NULL auto_increment, `AlbumName` varchar(100) NOT NULL, `AlbumShot` varchar(100) NOT NULL, PRIMARY KEY (`AlbumID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; CREATE TABLE `gallery` ( `GalleryID` int(4) unsigned zerofill NOT NULL auto_increment, `AlbumID` int(4) unsigned zerofill NOT NULL, `GalleryName` varchar(100) NOT NULL, `GalleryShot` varchar(100) NOT NULL, PRIMARY KEY (`GalleryID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
<html> <head> <title>ThaiCreate.Com Tutorial</title> <link media="screen" rel="stylesheet" href="colorbox.css" /> <script type="text/javascript" src="scripts/jquery.min.js"></script> <script type="text/javascript" src="colorbox/jquery.colorbox.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".galery").colorbox({rel:'galery', slideshow:true}); }); </script> </head> <body> <?php $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); $strSQL = "SELECT * FROM album WHERE AlbumID = '".$_GET["AlbumID"]."' "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $objResult = mysql_fetch_array($objQuery); ?> <h1><?php echo $objResult["AlbumName"];?></h1> <?php $strSQL2 = "SELECT * FROM gallery WHERE AlbumID = '".$_GET["AlbumID"]."' ORDER BY GalleryID ASC "; $objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]"); echo"<table border=\"1\" cellspacing=\"1\" cellpadding=\"1\"><tr>"; $intRows = 0; while($objResult2 = mysql_fetch_array($objQuery2)) { echo "<td>"; $intRows++; ?> <center> <a href="myfile/<?php echo $objResult2["GalleryShot"];?>" class="galery" title="<?php echo $objResult2["GalleryName"];?>"><img src="myfile/<?php echo $objResult2["GalleryShot"];?>" width="100" height="100"></a><br> <?php echo $objResult2["GalleryName"];?> <br> </center> <?php echo"</td>"; if(($intRows)%4==0) { echo"</tr>"; } } echo"</tr></table>"; mysql_close($objConnect); ?> </body> </html>