<? $host="localhost"; $username="root"; $password="root"; $db="ppponline"; mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ "); mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */ /*mysql_query("SET NAMES TIS620"); */ $sql = "select * from product order by id_pro asc limit 6 "; $db_query=mysql_db_query($db,$sql); $num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */ if(empty($num_rows)) /* ตรวจสอบว่ามีอยู่หรือยัง */ { echo"<center><br>ไม่พบข้อมูล <b>$keyword</b> จาก Filed <b>$fields <b> </center>"; exit(); } else { ?> <? $result = mysql_fetch_array($db_query); $id_pro=$result[id_pro]; $name_pro1=$result[name_pro1]; $name_pro2=$result[name_pro2]; $picture_pro=$result[picture_pro]; $band=$result[band]; $detail1=$result[detail1]; $detail2=$result[detail2]; $detail3=$result[detail3]; $detail4=$result[detail4]; $detail5=$result[detail5]; ?> <? $dquery = sprintf("select * from product order by id_pro asc limit 6 "); $rs= mysql_query($dquery) or die("Cannot connect to database"); $r = mysql_fetch_array($rs); ?> <!-- สร้างตารางเดียว --> <table width="100%"> <? do{ ?> <tr> <td width="50%"><img src=" pic/<?php echo $r['picture_pro']; ?>" height='80' border="1" align=LEFT> <font face="MS Sans Serif" size="2"> <font size="1"> <font size="2"> <?php echo $r['name_pro1']; ?> <font face="MS Sans Serif"><a href="Activity-detail.php?id=<?php echo $r['id_pro']; ?>" ><b><font color="#0033FF" size="1"><br> <span style="text-decoration: none"> อ่านต่อ<font color="#000000">></font><font color="#666666">><font color="#999999">></font></font></font></b></a></span></font></td> <? if( ($r = mysql_fetch_array($rs)) != NULL ) { ?> <td width="50%"><font face="MS Sans Serif" size="2"><img src=" pic/<?php echo $r['picture_pro']; ?>" height='80' border="1" align=LEFT> <?php echo $r['name_pro1']; ?> </font><font face="MS Sans Serif" size="1"> </font> <font face="MS Sans Serif"><a href="Activity-detail.php?id=<?php echo $r['id_pro']; ?>" ><b><font color="#0033FF" size="1"><br> <span style="text-decoration: none">อ่านต่อ<font color="#000000">></font><font color="#666666">><font color="#999999">></font></font></font></b></a></span></font></td> <? } } while ($r = mysql_fetch_array($rs)); ?> </tr> </table> <? } ?>
<html> <head> <title>ThaiCreate.Com Tutorial</title> </head> <body> <? $objConnect = mysql_connect("localhost","root","root") or die(mysql_error()); $objDB = mysql_select_db("mydatabase"); $strSQL = "SELECT * FROM gallery"; $objQuery = mysql_query($strSQL); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 4; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by GalleryID ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); echo"<table border=\"0\" cellspacing=\"1\" cellpadding=\"1\"><tr>"; $intRows = 0; while($objResult = mysql_fetch_array($objQuery)) { echo "<td>"; $intRows++; ?> <center> <img src="shotdev/<?=$objResult["Picture"];?>"><br> <?=$objResult["GalleryName"];?> <br> </center> <? echo"</td>"; if(($intRows)%2==0) { echo"</tr>"; } } echo"</tr></table>"; ?> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> "; } ?> </body> </html> <? mysql_close($objConnect); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง