<?php /* สมมติว่า ผมเชื่อมต่อฐานข้อมูลแล้ว(ตัวแปรที่เชื่อมต่อคือ $link ในตารางผมมี 2 ฟิว คือ ฟิวแรกคือ Image ฟิวสองคือ Link */ $sql = "SELECT * FROM table WHERE Condition"; $result = mysqli_query($link, $sql); $dbarr = mysqli_fetch_array($result); // แสดงภาพ echo "<img src=$dbarr[Image]>"; // แสดงลิงก์ echo "<a href=$dbarr[Link]>Your Menu</a>"; ?>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="0"> <tr><th>Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?=(isset($_GET['txtKeyword'])) ? $_GET['txtKeyword'] : '';?>"> <input type="submit" value="Search"></th></tr> </table></form></div> <?php $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database"); $objDB = mysql_select_db("sample"); $txtKeyword = (isset($_GET['txtKeyword'])) ? $_GET['txtKeyword'] : ''; $strSQL = "SELECT * FROM customer WHERE (Name LIKE '%".$txtKeyword."%' or Email LIKE '%".$txtKeyword."%' )"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <div align="center"> <table border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> <th width="100"> <div align="center">Link </div></th> <th width="100"> <div align="center">Picture </div></th></tr> </div> <?php while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["CustomerID"];?></div></td> <td><?=$objResult["Name"];?></td> <td><?=$objResult["Email"];?></td> <td><div align="center"><?=$objResult["CountryCode"];?></div></td> <td align="right"><?=number_format($objResult["Budget"],2);?></td> <td align="right"><?=number_format($objResult["Used"],2);?></td> <td><?=$objResult["Link"];?></td> <td><?=$objResult["Picture"];?></td> </tr>
<td><a href="<?=$objResult["Link"];?>">ส่วนนี้คือชื่อที่แสดงผลของลิงกก์</a></td>
<td><img src="<?=$objResult["Picture"];?>"></td>
<td><img src="โฟลเดอร์รูป/ชื่อไฟล์รูป.jpg"<?=$objResult["Picture"];?>"></td>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง