Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถามเรื่อง php ลิ้งหน้าต่อไปแสดงเป็น หน้า1, 2, 3 ,4...



 

สอบถามเรื่อง php ลิ้งหน้าต่อไปแสดงเป็น หน้า1, 2, 3 ,4...

 



Topic : 106717

Guest




Code (PHP)
<?
if($_GET["txtKeyword"]!= " mm_name")
	{
	$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
	$objDB = mysql_select_db("rmuttsocial");
	mysql_query("SET NAMES utf8", $objConnect);
	// Search By Name or Email
	$strSQL = "SELECT * FROM tbl_member  WHERE (mm_name  LIKE '%".$_GET["txtKeyword"]."%'   or   type LIKE '%".$_GET["txtKeyword" ]."%')";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mysql_num_rows($objQuery);

$Per_Page = 2;   // 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 CustomerID ASC LIMIT $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
	?>
	<table width="400" border="1">
	  <tr>
		<th width="91"> <div align="center">ID</div></th>
		<th width="98"> <div align="center">Name</div></th>
		<th width="198"> <div align="center">Date</div></th>
		<th width="97"> <div align="center">type</div></th>
	  </tr>
	<?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	  <tr>
		<td><div align="center"><?=$objResult["mm_id"];?></div></td>
		<td><div align="center"><?=$objResult["mm_name"];?></div></td>
		<td><div align="center"><?=$objResult["bday"];?></div></td>
		<td><div align="center"><?=$objResult["type"];?></div></td>
	  </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> ";
}
mysql_close($objConnect);
?>




Tag : PHP, HTML/CSS







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-09 12:59:05 By : joon View : 677 Reply : 6
 

 

No. 1

Guest


ติด error เพราะอะไรค่ะ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 13:00:50 By : joon
 


 

No. 2



โพสกระทู้ ( 1,569 )
บทความ ( 2 )



สถานะออฟไลน์
Twitter Facebook Blogger

error ว่าอะไรล่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 13:04:18 By : itpcc
 

 

No. 3

Guest


Parse error: syntax error, unexpected $end in C:\AppServ\www\project\search.php ค่ะไม่รู้เพราะอะไร
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 13:11:40 By : joon
 


 

No. 4

Guest


รูป
Code (PHP)
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="400" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword"   type="text"   id="txtKeyword"  value="<?=$_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<?
if($_GET["txtKeyword"]!= " mm_name")
	{
	$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
	$objDB = mysql_select_db("rmuttsocial");
	mysql_query("SET NAMES utf8", $objConnect);
	// Search By Name or Email
	$strSQL = "SELECT * FROM tbl_member  WHERE (mm_name  LIKE '%".$_GET["txtKeyword"]."%'   or   type LIKE '%".$_GET["txtKeyword" ]."%')";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mysql_num_rows($objQuery);


	$Per_Page = 2;   // 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 inid ASC LIMIT $Page_Start , $Per_Page";
	$objQuery  = mysql_query($strSQL);

	?>
	<table width="400" border="1">
	  <tr>
		<th width="91"> <div align="center">ID</div></th>
		<th width="98"> <div align="center">Name</div></th>
		<th width="198"> <div align="center">Date</div></th>
		<th width="97"> <div align="center">type</div></th>
	  </tr>
	<?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	  <tr>
		<td><div align="center"><?=$objResult["mm_id"];?></div></td>
		<td><div align="center"><?=$objResult["mm_name"];?></div></td>
		<td><div align="center"><?=$objResult["bday"];?></div></td>
		<td><div align="center"><?=$objResult["type"];?></div></td>
	  </tr>
	<?
	}
	?>
	</table>

	<br>
	Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
	<?
	if($Prev_Page)
	{
		echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_POST[txtKeyword]'><< Back</a> ";
	}

	for($i=1; $i<=$Num_Pages; $i++){
		if($i != $Page)
		{
			echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_POST[txtKeyword]'>$i</a> ]";
		}
		else
		{
			echo "<b> $i </b>";
		}
	}
	if($Page!=$Num_Pages)
	{
		echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_POST[txtKeyword]'>Next>></a> ";
	}

	}	
?>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 13:38:01 By : ่joon
 


 

No. 5

Guest


ช่วยดูให้หน่อยค่ะ ว่าติดเพราะอะไร
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 13:39:27 By : joon
 


 

No. 6

Guest


Code (PHP)
$_POST[txtKeyword]

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-09 18:44:56 By : ผู้มาเยือน
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเรื่อง php ลิ้งหน้าต่อไปแสดงเป็น หน้า1, 2, 3 ,4...
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 01
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่