![]() |
|
|
#1 | ||
|
HotDog
เป็นสมาชิกเมื่อ: Jan 2009
ที่อยู่: Bangkok
โพส: 167
|
ขอบคุณบทความดี ๆ จาก
http://www.thaicreate.com PHP MySQL Search Record Paging ตัวอย่างนี้จะเป็นการเขียนโปรแกรม PHP กับ MySQL เพื่อค้นหาข้อมูลจาก Table มาแสดงและมีการแบ่งการแสดงผลเป็นหน้า ตัวอย่าง phpMySQLSearchRecordPaging.php PHP Code:
จากตัวอย่างโค้ดด้านบนผลการแสดงออกมาจะได้ดังภาพ ![]() ลองเล่นกันดูนะครับ
__________________
Ethaidesign.com The Communities Graphic & Developer free forums.![]() |
||
|
|
|
|
|
#2 | ||
|
สมาชิกบอร์ด
เป็นสมาชิกเมื่อ: Feb 2009
โพส: 1
|
รบกวนสอบถามครับ
จากวิธีที่แนะนำมา ผมมาเปลี่ยนในส่วนช่องสำหรับใส่ keyword เป็น 2 ช่อง ตามโค้ดนี้ <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">และ<br> <input name="txtKeyword1" type="text1" id="txtKeyword1" value="<?=$_GET["txtKeyword1"];?>"> <input type="submit" value="Search"></font></th> </tr> </table> </form> <? if($_GET["txtKeyword"]["txtKeyword1"] != "") { $objConnect = mysql_connect("localhost","root","") or die("Error Connect to Database"); $objDB = mysql_select_db("xxxx"); // Search By Name or Email $strSQL = "SELECT * FROM ratchakitcha WHERE (title LIKE '%".$_GET["txtKeyword"]."%' or volume LIKE '%".$_GET["txtKeyword"]."%' or part LIKE '%".$_GET["txtKeyword"]."%' or year LIKE '%".$_GET["txtKeyword"]."%') and (title LIKE '%".$_GET["txtKeyword1"]."%' or volume LIKE '%".$_GET["txtKeyword1"]."%' or part LIKE '%".$_GET["txtKeyword1"]."%' or year LIKE '%".$_GET["txtKeyword1"]."%')Order by title"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); ใช้ and ในการเชื่อม keyword ทั้ง 2 คำแล้วลอง search ดูปรากฎว่า ได้ผลครับ ผลการสืบค้นต้องมี keyword ทั้ง2 คำปรากฎ ทำให้ข้อมูลแคบลงครับ พอกด next เพื่อดูหน้าถัดไป มันกลับแสดงผลเป็นเช่นเดียวกับการค้น โดยใช้ keyword แรกคำเดียวครับ ผมจะต้องแก้ยังไงครับ ปล.ผมอธิบายงงป่ะ อีเมลผม hunter-xx@windowslive.com |
||
|
|
|
![]() |
| คำค้น (Tags) |
| การดึงข้อมูล mysql, ค้นหา แสดงผลเป็นหน้า, ดึงข้อมูล แสดงผลเป็นหน้า, ดึงข้อมูลจากฐานข้อมูล |
| Thread Tools | |
|
|