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 > สอบถามการใส่โค๊ดเข้าไปเพื่อแบ่งหน้า จากข้อมูลที่ค้นหาในดาต้าเบสครับ



 

สอบถามการใส่โค๊ดเข้าไปเพื่อแบ่งหน้า จากข้อมูลที่ค้นหาในดาต้าเบสครับ

 



Topic : 106859



โพสกระทู้ ( 4 )
บทความ ( 0 )



สถานะออฟไลน์




โดยปกติโค๊ดชุดนี้เมื่อค้นหาข้อมูลมันจะแสดงหน้าเดียวซึ่งมันเยอะมากครับ

ต้องการที่จะให้มันแสดงข้อมูลต่อหน้าซัก 100หรือ50ก็ได้ครับ จะต้องใช้แบบไหน แล้วเอาไปใส่ตรงไหนครับ

คือปมดูที่มีๆอยู่แล้วยังไม่ค่อยกระจ่าง รบกวนช่วยสอนด้วยครับ ขอบคุณครับ

Code (PHP)
<div align="center">

  <form id="form_search" name="form_search" method="post" action="customer_search.php">
  <table width="920" border="0" bgcolor="#f3f1eb">
  <tr>
      <td width="505"></td>
      <td width="159">
    ค้นหาจาก  <label for="cb_serach"></label>
    <select name="cb_serach" id="cb_serach">
      <option selected="selected">รหัสลูกค้า</option>
      <option>ชื่อ </option>
      <option>นามสกุล</option>
      <option>ชื่อ - นามสกุล</option>
      <option>เบอร์โทรศัพท์</option>
      <option>รหัสไปรษณีย์</option>
    </select></td>
    <td width="44">ค้นหา<label for="txt_search"></label></td>
    <td width="144"><input type="text" name="txt_search" id="txt_search" /></td>
    <td width="46"><input type="submit" name="btn_search" id="btn_search" value="ค้นหา" /></td>
    </tr>
    </table>
  </form>
	
    



<?
	$text = $_POST["txt_search"];
	$listdata = $_POST["cb_serach"];
	if(trim($_POST["txt_cus_id"]) != ""){
		$listdata = "รหัสลูกค้า";
		$text = trim($_POST["txt_cus_id"]);
		//$text = "46000267";
		
	}else if(trim($_POST["txt_name_last"]) != ""){
		$listdata = "ชื่อ - นามสกุล";
		$text = trim($_POST["txt_name_last"]);
	}
	else if(trim($_POST["txt_name"]) != ""){
		$listdata = "ชื่อ";
		$text = trim($_POST["txt_name"]);
	}
	else if(trim($_POST["txt_last"]) != ""){
		$listdata = "นามสกุล";
		$text = trim($_POST["txt_last"]);
	}
	else if(trim($_POST["txt_mobile"]) != ""){
		$listdata = "เบอร์โทรศัพท์";
		$text = trim($_POST["txt_mobile"]);
	}
	else if(trim($_POST["txt_postalcode"]) != ""){
		$listdata = "รหัสไปรษณีย์";
		$text = trim($_POST["txt_postalcode"]);
	}
	else if(trim($_POST["txt_postalcode"]) != ""){
		$listdata = "รหัสไปรษณีย์";
		$text = trim($_POST["txt_postalcode"]);
	}
	else if(trim($_POST["txt_serial"]) != ""){
		$listdata = "S/N";
		$text = trim($_POST["txt_serial"]);
	}
	

if($text != "")
	{
		
		
		$textA = split(' ',$text);
		
		
		
		include_once("script/php/connect.php");
		include_once("script/php/db_customer.php");
		

		$SQL = "select  cus.cus_id,cus.cus_firstname , cus.cus_lastname ,(select provinceName from province where provinceId = cus.cus_province) as province , (select districtName from district where districtId = cus.cus_district) as district , (select amphurName from amphur where amphurId = cus.cus_sub_district) as aumphur, cus_address,cus_postalcode , cus.cus_mobilephone from  customer as cus ";
		if($listdata == "รหัสลูกค้า"){

			$SQL .= " WHERE cus_id LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata == "ชื่อ"){
			$SQL .= " WHERE cus_firstname LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata ==  "นามสกุล"){
			$SQL .= " WHERE cus_lastname LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata ==  "ชื่อ - นามสกุล"){
			$SQL .= " WHERE cus_firstname LIKE '%$textA[0]%' or cus_lastname LIKE '%$textA[1]%' order by cus_id asc" ;		
		}
		else if($listdata ==  "เบอร์โทรศัพท์"){
			$SQL .= " WHERE cus_mobilephone LIKE '%$text%' order by cus_id asc";	
		}
		else if($listdata ==  "รหัสไปรษณีย์"){
			$SQL .= " WHERE cus_postalcode LIKE '$text' order by cus_id asc";	
		}
		else if($listdata ==  "S/N"){
			$SQL = "select customer.cus_id,cus_firstname,cus_lastname,cus_mobilephone,cus_address,(select provinceName from province where provinceId = customer.cus_province) as province ,(select districtName from district where districtId = customer.cus_district) as district,(select amphurName from amphur where amphurId = customer.cus_sub_district) as aumphur,cus_postalcode,customer_product.serial_number from customer left join customer_product on customer.cus_id=customer_product.cus_id where serial_number LIKE '%$text%' order by cus_id asc";	
		}
		else{
			
			$SQL .= " where cus_firstname = '$textA[1]' and cus_lastname =  '$textA[2]' and cus_id = '$textA[0]'  order by cus_id asc";
		}
		
		$select = mysql_select_db("crm", connect_db());
		$query = mysql_query($SQL);
		
	?>
	<table width="920" border="1"  cellspacing="0">
	  <tr bgcolor="#f3f1eb" bordercolor="#00CC99">
		<th width="87" align="center"> รหัสลูกค้า </th>
		<th width="120" align="center"> ชื่อ - นามสกุล</th>
		<th width="50" align="center"> เบอร์ </th>
		<th width="150" align="center"> ที่อยู่ </th>
		<th width="30" align="center"> ตำบล/แขวง </th>
		<th width="30" align="center"> อําเภอ/เขต  </th>
        <th width="30" align="center"> จังหวัด</th>
        <th width="30" align="center">ไปรษณีย์</th>
		<?php
        	if($listdata ==  "S/N"){
	  			echo "<th width='70' align='center'> S/N </th>";
	  		}
	  	?>
	  	<th width="70" align="center"> แก้ไข</th>
        <th width="10" align="center"> ดูข้อมูล</th>
      </tr>
	<?
	while($result = mysql_fetch_array($query))
	{
	?>
	  <tr>
		<td align="center"><?=$result["cus_id"];?></td>
		<td><?=$result["cus_firstname"] . " " . $result["cus_lastname"];?></td>
		<td><?=$result["cus_mobilephone"];?></td>
		<td align="left"><?=$result["cus_address"];?></td>
		<td align="left"><?=$result["district"];?></td>
		<td align="left"><?=$result["aumphur"];?></td>
        <td align="left"><?=$result["province"];?></td>
		<td align="center"><?=$result["cus_postalcode"];?></td>
		<?php
        	if($listdata ==  "S/N"){
	  			echo "<td align='center'>$result[serial_number]</td>";
	  		}
	  	?>
        <td align="center"><a href="customer_edit.php?cus_id=<?=$result["cus_id"]?>">แก้ไข</a></td>
         <!--<td align="center"><a href="customer_view.php?cus_id=<?=$result["cus_id"]?>">ดูข้อมูล</a></td>-->
	  </tr>
	<?
	}
	?>
	</table>
	<?
	
}
?>
</div>




Tag : PHP, MySQL, HTML/CSS, Action Script, Windows







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-03-13 13:34:08 By : midnightsara View : 640 Reply : 3
 

 

No. 1



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



สถานะออฟไลน์


ดัดแปลงเอาครับ ไม่ยากอะไรเลย -->การแสดงแบบแบ่งหน้าโดยใช้ kgPager Class (PHP & MySQL)






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-13 14:03:11 By : arm8957
 


 

No. 2



โพสกระทู้ ( 27 )
บทความ ( 0 )



สถานะออฟไลน์


ลองใช้ Jquery Tablesorter ครับ

http://tablesorter.com/docs/
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-13 15:21:24 By : Berbatov23
 

 

No. 3

Guest


แบ่งหน้าได้แล้วครับ แต่พอกดหน้าต่อไปไม่มีข้อมูลครับ ไม่ทราบว่าเป็นที่จุดไหนครับ ขอบคุณครับ


Code (PHP)
<form id="form_search" name="form_search" method="post" action="customer_search.php">
  
  <table width="920" border="0" bgcolor="#f3f1eb">
  <tr>
      <td width="505"></td>
      <td width="159">
    ค้นหาจาก  <label for="cb_serach"></label>
    <select name="cb_serach" id="cb_serach">
      <option selected="selected">รหัสลูกค้า</option>
      <option>ชื่อ </option>
      <option>นามสกุล</option>
      <option>ชื่อ - นามสกุล</option>
      <option>เบอร์โทรศัพท์</option>
      <option>รหัสไปรษณีย์</option>
    </select></td>
    <td width="44">ค้นหา<label for="txt_search"></label></td>
    <td width="144"><input type="text" name="txt_search" id="txt_search" value="<?=$_POST["txt_search"];?>" /> </td>
    <td width="46"><input type="submit" name="btn_search" id="btn_search" value="ค้นหา" /></td>
    </tr>
    </table>
  </form>
	
    



<?
	$text = $_POST["txt_search"];
	$listdata = $_POST["cb_serach"];
	if(trim($_POST["txt_cus_id"]) != ""){
		$listdata = "รหัสลูกค้า";
		$text = trim($_POST["txt_cus_id"]);
		//$text = "46000267";
		
	}else if(trim($_POST["txt_name_last"]) != ""){
		$listdata = "ชื่อ - นามสกุล";
		$text = trim($_POST["txt_name_last"]);
	}
	else if(trim($_POST["txt_name"]) != ""){
		$listdata = "ชื่อ";
		$text = trim($_POST["txt_name"]);
	}
	else if(trim($_POST["txt_last"]) != ""){
		$listdata = "นามสกุล";
		$text = trim($_POST["txt_last"]);
	}
	else if(trim($_POST["txt_mobile"]) != ""){
		$listdata = "เบอร์โทรศัพท์";
		$text = trim($_POST["txt_mobile"]);
	}
	else if(trim($_POST["txt_postalcode"]) != ""){
		$listdata = "รหัสไปรษณีย์";
		$text = trim($_POST["txt_postalcode"]);
	}
	else if(trim($_POST["txt_serial"]) != ""){
		$listdata = "S/N";
		$text = trim($_POST["txt_serial"]);
	}
	

if($text != "")
	{
		
		
		$textA = split(' ',$text);
		
		
		
		include_once("script/php/connect.php");
		include_once("script/php/db_customer.php");
		
	
	//$SQL = "SELECT * FROM customer WHERE cus_firstname LIKE '%".$_POST["txt_search"]."%' or cus_lastname LIKE '%".$_POST["txt_search"]."%' or cus_id LIKE '%".$_POST["txt_search"]."%' or cus_mobilephone LIKE '%".$_POST["txt_search"]."%' )" ;
	
	
	
	
		//$query = mysql_query($sql);
		//$result  = mysql_db_query($select,$sql);
		//$result = mysql_num_rows($query); 
		$SQL = "select  cus.cus_id,cus.cus_firstname , cus.cus_lastname ,(select provinceName from elvira_crm.province where provinceId = cus.cus_province) as province , (select districtName from elvira_crm.district where districtId = cus.cus_district) as district , (select amphurName from elvira_crm.amphur where amphurId = cus.cus_sub_district) as aumphur, cus_address,cus_postalcode , cus.cus_mobilephone from  elvira_crm.customer as cus ";
		if($listdata == "รหัสลูกค้า"){
			$SQL .= " WHERE cus_id LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata == "ชื่อ"){
			$SQL .= " WHERE cus_firstname LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata ==  "นามสกุล"){
			$SQL .= " WHERE cus_lastname LIKE '%$text%' order by cus_id asc";
		}
		else if($listdata ==  "ชื่อ - นามสกุล"){
			$SQL .= " WHERE cus_firstname LIKE '%$textA[0]%' or cus_lastname LIKE '%$textA[1]%' order by cus_id asc" ;		
		}
		else if($listdata ==  "เบอร์โทรศัพท์"){
			$SQL .= " WHERE cus_mobilephone LIKE '%$text%' order by cus_id asc";	
		}
		else if($listdata ==  "รหัสไปรษณีย์"){
			$SQL .= " WHERE cus_postalcode LIKE '$text' order by cus_id asc";	
		}
		else if($listdata ==  "S/N"){
			$SQL = "select customer.cus_id,cus_firstname,cus_lastname,cus_mobilephone,cus_address,(select provinceName from elvira_crm.province where provinceId = customer.cus_province) as province ,(select districtName from elvira_crm.district where districtId = customer.cus_district) as district,(select amphurName from elvira_crm.amphur where amphurId = customer.cus_sub_district) as aumphur,cus_postalcode,customer_product.serial_number from customer left join customer_product on customer.cus_id=customer_product.cus_id where serial_number LIKE '%$text%' order by cus_id asc";	
		}
		else{
			
			$SQL .= " where cus_firstname = '$textA[1]' and cus_lastname =  '$textA[2]' and cus_id = '$textA[0]'  order by cus_id asc";
		}
		
		$select = mysql_select_db("elvira_crm", connect_db());
		$query = mysql_query($SQL);
		/* ////////////////////////////////////////////////////////////////////////////// */
			$query = mysql_query($SQL) or die ("Error Query [".$SQL."]");
			$Num_Rows = mysql_num_rows($query);
		
		
			$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 cus_id ASC LIMIT $Page_Start , $Per_Page";
			$query  = mysql_query($SQL);
		
	?>
	<table width="920" border="1"  cellspacing="0">
	  <tr bgcolor="#f3f1eb" bordercolor="#00CC99">
		<th width="87" align="center"> รหัสลูกค้า </th>
		<th width="120" align="center"> ชื่อ - นามสกุล</th>
		<th width="50" align="center"> เบอร์ </th>
		<th width="150" align="center"> ที่อยู่ </th>
		<th width="30" align="center"> ตำบล/แขวง </th>
		<th width="30" align="center"> อําเภอ/เขต  </th>
        <th width="30" align="center"> จังหวัด</th>
        <th width="30" align="center">ไปรษณีย์</th>
		<?php
        	if($listdata ==  "S/N"){
	  			echo "<th width='70' align='center'> S/N </th>";
	  		}
	  	?>
	  	<th width="70" align="center"> แก้ไข</th>
        <th width="10" align="center"> ดูข้อมูล</th>
      </tr>
	<?
	while($result = mysql_fetch_array($query))
	{
	?>
	  <tr>
		<td align="center"><?=$result["cus_id"];?></td>
		<td><?=$result["cus_firstname"] . " " . $result["cus_lastname"];?></td>
		<td><?=$result["cus_mobilephone"];?></td>
		<td align="left"><?=$result["cus_address"];?></td>
		<td align="left"><?=$result["district"];?></td>
		<td align="left"><?=$result["aumphur"];?></td>
        <td align="left"><?=$result["province"];?></td>
		<td align="center"><?=$result["cus_postalcode"];?></td>
		<?php
        	if($listdata ==  "S/N"){
	  			echo "<td align='center'>$result[serial_number]</td>";
	  		}
	  	?>
        <td align="center"><a href="customer_edit.php?cus_id=<?=$result["cus_id"]?>">แก้ไข</a></td>
         <!--<td align="center"><a href="customer_view.php?cus_id=<?=$result["cus_id"]?>">ดูข้อมูล</a></td>-->
	  </tr>
	<?
	}
	?>
	</table>
    
	<?
	
}
?>
	
    	Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
	<?
	if($Prev_Page)
	{
		echo " <a href='$_SERVER[PHP_SELF]?Page=$Prev_Page&txt_search=$_POST[txt_search]'><< Back</a> ";

	}

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

		
	?>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-03-14 11:33:26 By : midnightsara
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามการใส่โค๊ดเข้าไปเพื่อแบ่งหน้า จากข้อมูลที่ค้นหาในดาต้าเบสครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 อัตราราคา คลิกที่นี่