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 > ช่วยดูโค้ดให้หน่อยนะครับผมต้องการ ค้นหาข้อมูล จาก ฟิวส์ 5 ฟิวส์



 

ช่วยดูโค้ดให้หน่อยนะครับผมต้องการ ค้นหาข้อมูล จาก ฟิวส์ 5 ฟิวส์

 



Topic : 058891



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



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




ตัวอย่างโค้ด คือตอนนี้ค้นหาอะไรก็เจอที่ฟิวส์แรก อยากจะทราบต้องให้ GET ชื่อฟิวส์ หรือว่า GET form ครับ รบกวนผู้รู็หน่อยนะครับ เสียเวลามาหลายวันแล้วครับ


Code (PHP)
 <?php require_once('./Connections/db_conn.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editprofile </title>
<style type="text/css">
<!--
body,td,th {
	font-family: MS Sans Serif, AngsanaUPC, Arial;
	font-size: 14px;
}
.style4 {color: #3399FF}s
a:link {
	color: #0066FF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
	color: #999999;
}
a:active {
	text-decoration: none;
}
-->
</style></head>

<body>
<table width="241" height="0" border="0" cellpadding="0" cellspacing="0">
</table>

</table>
<table width="700" height="104" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"> 
          <table width="678" height="48" border="0" cellpadding="0" cellspacing="0">
        <tr><script language="javascript">
  
 
 function fncSubmit(){  
     if(confirm.form2.selectdelete.value=="profilecomputer"('ยืนยัน กด OK')==true)
     {
         document.form2.submit();
     
	 }
 }
 </script>
          <td width="289" valign="bottom"><form id="form2" name="form2" method="post" action="DeleteAll.php" onsubmit="return chkin()">
            <table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>    <script language="javascript">
  function chkin(){
       if(document.form2.selectdelete.value=="no"){
             alert("ต้องเลือกฐานข้อมูลก่อนนะครับ");
              document.form2.selectdelete.focus();
              return false; 
        }          
     }
 </SCRIPT>
                <td width="123"><label>
                  <select name="selectdelete" id="selectdelete">
                    <option selected value="no">-เลือกฐานข้อมูล-</option>
                    <option value="profilecomputer">profilecomputer</option>
                    <option value="profile_temp">profile_temp</option>
                  </select>
                </label></td>
                <td width="77">  <label>
                  <input type="submit" name="button2" id="button2" value="Remove All" OnClick="JavaScript:fncSubmit();" />
                </label></td>
              </tr>
            </table>
                    </form>
          </td>
          <td width="389"><form id="form1" name="form1" method="GET" action="<?=$_SERVER['SCRIPT_NAME'];?>">
      <table width="337" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="92" height="27"><div align="center"><span class="style4">COMID</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword1" id="txtKeyword1" value="<?=$_GET["txtKeyword1"];?>">
            </label></td>
          </tr>
        <tr>
          <td height="27"><div align="center"><span class="style4">COMSN</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword2" id="txtKeyword2" value="<?=$_GET["txtKeyword2"];?>"  />
            </label></td>
          </tr>
        <tr>
          <td height="27"><div align="center"><span class="style4">NAME</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword3" id="txtKeyword3" />
            </label></td>
          </tr>
        <tr>
          <td height="28"><div align="center"><span class="style4">BRAND</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword4" id="txtKeyword4" />
            </label></td>
          </tr>
        <tr>
          <td height="26"><div align="center"><span class="style4">TYPE</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword5" id="txtKeyword5" />
            </label></td>
          </tr>
        <tr>
          <td> </td>
            <td width="41"> </td>
            <td width="63"><label>
              <input type="submit" name="button" id="button" value="Serach" />
            </label></td>
            <td width="141"> </td>
          </tr>
        <tr>
          <td> </td>
            <td colspan="3"> </td>
          </tr>
        </table>
          </form></td>
        </tr>
      </table>
      
      <p> <hr width="150%"  style="border:0px;border-bottom:1px dashed #000" /></p>
      <p>
        <?php
if($_GET["txtKeyword1"] != "")
	{
	 mysql_connect($hostname_db_conn,$username_db_conn,$password_db_conn);  
    mysql_select_db($database_db_conn); 
	mysql_query('SET CHARACTER SET utf8');
	// Search By Name
	$strSQL = "SELECT  * FROM profilecomputer  WHERE (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  ";    
	 
	    
	
	
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mysql_num_rows($objQuery);


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

	?>
      </p>
      
      <table width="150%" border="1">
        <tr bgcolor="#00FFFF">
          <!--<th width="91"> <div align="center">CustomerID </div></th> -->
          <th width="20%"> <div align="center">comid</div></th>
	      <th width="14%"> <div align="center">comsn</div></th>
	      <th width="13%"> <div align="center">name</div></th>
          <th width="12%"> <div align="center">brand</div></th>
          <th width="14%"> <div align="center">type</div></th>
          <th width="12%"> <div align="center">Detail</div></th>
          <th width="7%"> <div align="center">Edit</div></th>
          <th width="8%"> <div align="center">Dlete</div></th>
        </tr>
        <?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
        <tr>
          <td height="23"><div align="center"><?=$objResult["comID"];?></div></td>
	      <td align="center"><?=$objResult["comSN"];?></td>
	      <td align="center"><?=$objResult["ownTn"];?></td>
   	        <td align="center"><?=$objResult["Brand"];?></td>
       	        <td align="center"><?=$objResult["TYPE"];?></td>
          <td align="center"><a href="detail.php?comID=<?=$objResult["comID"];?>">ดูรายละเอียด</a></td>
          <td align="center"><a href="formEdit.php?comID=<?=$objResult["comID"];?>">แก้ไข</a></td>
           <td align="center"><a href="Delete.php?comID=<?=$objResult["comID"];?>">Dlete</a></td>
        </tr>
        <?
	}
	?>
      </table>
      <br>
      จำนวนทั้งหมด 
      <?= $Num_Rows;?> 
      หน้า หน้าที่ : 
      <?=$Num_Pages;?> 
      หน้า :
    <?
	if($Prev_Page)
	{
		echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword1=$_GET[txtKeyword1]'><< Back</a> ";
	}

	for($i=1; $i<=$Num_Pages; $i++){
		if($i != $Page)
		{
			echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword1=$_GET[txtKeyword1]'>$i</a> ]";
		}
		else
		{
			echo "<b> $i </b>";
		}
	}
	if($Page!=$Num_Pages)
	{
		echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword1=$_GET[txtKeyword1]'>Next>></a> ";
	}
	
	mysql_close( );
 
	}	
	?>    </td> 
  </tr>
</table>
</body>
</html>





Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-04-20 13:48:57 By : thelak View : 850 Reply : 11
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" border="1">
    <tr>
      <th>Country Code 
        <select name="ddlCountryCode" id="ddlCountryCode">
          <option>- Select Country Code -</option>
          <option value="TH">TH</option>
          <option value="EN">EN</option>
          <option value="US">US</option>
        </select>
        Keyword
        <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<?

	$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
	$objDB = mysql_select_db("mydatabase");
	// Search By Name or Email
	$strSQL = "SELECT * FROM customer WHERE 1  ";
	if($_POST["ddlCountryCode"] != "")
	{
	 $strSQL .= " AND (CountryCode = '".$_POST["ddlCountryCode"]."') ";
	}	
	if($_POST["txtKeyword"] != "")
	{
	 $strSQL .= " AND (Name LIKE '%".$_POST["txtKeyword"]."%' or Email LIKE '%".$_POST["txtKeyword"]."%' ) ";
	}
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	?>
	<table width="600" 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>
	  </tr>
	<?
	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"><?=$objResult["Budget"];?></td>
		<td align="right"><?=$objResult["Used"];?></td>
	  </tr>
	<?
	}
	?>
	</table>
	<?
	mysql_close($objConnect);
?>
</body>
</html>


อันนี้ 2 ฟิวด์ครับ ลองดูครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 13:51:59 By : webmaster
 


 

No. 2



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



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


โค้ดเริ่มตั้ง บรรทัด 77-142 ที่มันทำงานครับผม คือที่ทำเพราะว่าอยากให้การค้นหาให้มันแคบลงครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 13:52:37 By : thelak
 

 

No. 3



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



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


method="GET" น่าจะเปลี่ยนเป็น post นะครับ แล้วก็ รับข้อมูลแบบ post น่าจะดีกว่านะครับ ลองเปลี่ยนแบบนี้ดูนะคับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 13:52:46 By : SOUL
 


 

No. 4



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



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


ขอทำความเข้าใจกับ พี่วินหน่อยครับ ผมค้องทำประมาณนี้ใช่ไหมครับ อันนี้ไม่ใช่โค้ดที่ถูกต้องแต่ถ้าผมจะทำ 5 ฟิวส์ต้องเป็นประมาณนี้ไหมครับ
Code (PHP)
if($_POST["txtKeyword1"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  "; 
    }
	if($_POST["txtKeyword2"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  "; 
    }
	if($_POST["txtKeyword3"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  "; 
    }
	if($_POST["txtKeyword4"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  "; 
    }
	if($_POST["txtKeyword5"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword2"]."%' or ownTn LIKE '%".$_GET["txtKeyword3"]."%' or Brand LIKE '%".$_GET["txtKeyword4"]."%' or  TYPE LIKE '%".$_GET["txtKeyword5"]."%'  )  "; 
    }
	    

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 14:10:04 By : thelak
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

ทำไมจะต้องมี keyword ถึง 5 ตัวครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 14:33:47 By : webmaster
 


 

No. 6



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



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


ต้องประมาณนี้ใช่ไหมครับ ผมมือใหม่ครับ รบกวนหน่อยนะครับ
Code (PHP)
$strSQL = "SELECT  * FROM profilecomputer  WHERE  ";
	if($_POST["txtKeyword1"] != "")
     {
      $strSQL .= " or (comID LIKE '%".$_GET["txtKeyword1"]."%' ) "; 
    }
if($_POST["txtKeyword2"] != "")
     {
      $strSQL .= " or (comID LIKE '%".$_GET["txtKeyword2"]."%' ) "; 
    }
if($_POST["txtKeyword3"] != "")
     {
      $strSQL .= " or (comID LIKE '%".$_GET["txtKeyword3"]."%' ) "; 
    }
if($_POST["txtKeyword4"] != "")
     {
      $strSQL .= " or (comID LIKE '%".$_GET["txtKeyword4"]."%' ) "; 
    }
if($_POST["txtKeyword5"] != "")
     {
      $strSQL .= " or (comID LIKE '%".$_GET["txtKeyword5"]."%' ) "; 
    }

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 14:41:03 By : thelak
 


 

No. 7



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

Code (PHP)
if($_POST["txtKeyword1"] != "")
     {
      $strSQL .= " AND (comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword1"]."%' or ownTn LIKE '%".$_GET["txtKeyword1"]."%' or Brand LIKE '%".$_GET["txtKeyword1"]."%' or  TYPE LIKE '%".$_GET["txtKeyword1"]."%'  )  "; 
    }


แค่นี้ก็พอแล้วครับ เอาแค่ keyword เดียวแต่ or ได้ 5 ฟิวด์เลยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 14:57:19 By : webmaster
 


 

No. 8



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



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


ขอบคุณมากครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 15:08:10 By : thelak
 


 

No. 9



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



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


ผมทำแล้วมันไม้ได้ครับ เวลา ใส่คำค้นหาเจอแบบนี้ครับ Error Query [SELECT * FROM profilecomputer WHERE or (comID LIKE '%y' or (comSN LIKE '%y' or (ownTn LIKE '%y' or (Brand LIKE '%y' or (TYPE LIKE '%y' ]

ลอง or ลอง and ก็ไม่ได้ครับหรือผิดตรงไหนครับ


Code (PHP)
 <?php require_once('./Connections/db_conn.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Editprofile </title>
<style type="text/css">
<!--
body,td,th {
	font-family: MS Sans Serif, AngsanaUPC, Arial;
	font-size: 14px;
}
.style4 {color: #3399FF}s
a:link {
	color: #0066FF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
	color: #999999;
}
a:active {
	text-decoration: none;
}
-->
</style></head>

<body>
<table width="241" height="0" border="0" cellpadding="0" cellspacing="0">
</table>

</table>
<table width="700" height="104" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"> 
          <table width="678" height="48" border="0" cellpadding="0" cellspacing="0">
        <tr><script language="javascript">
  
 
 function fncSubmit(){  
     if(confirm.form2.selectdelete.value=="profilecomputer"('ยืนยัน กด OK')==true)
     {
         document.form2.submit();
     
	 }
 }
 </script>
          <td width="289" valign="bottom"><form id="form2" name="form2" method="post" action="DeleteAll.php" onsubmit="return chkin()">
            <table width="200" border="0" cellspacing="0" cellpadding="0">
              <tr>    <script language="javascript">
  function chkin(){
       if(document.form2.selectdelete.value=="no"){
             alert("ต้องเลือกฐานข้อมูลก่อนนะครับ");
              document.form2.selectdelete.focus();
              return false; 
        }          
     }
 </SCRIPT>
                <td width="123"><label>
                  <select name="selectdelete" id="selectdelete">
                    <option selected value="no">-เลือกฐานข้อมูล-</option>
                    <option value="profilecomputer">profilecomputer</option>
                    <option value="profile_temp">profile_temp</option>
                  </select>
                </label></td>
                <td width="77">  <label>
                  <input type="submit" name="button2" id="button2" value="Remove All" OnClick="JavaScript:fncSubmit();" />
                </label></td>
              </tr>
            </table>
                    </form>
          </td>
          <td width="389"><form id="form1" name="form1" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
      <table width="337" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="92" height="27"><div align="center"><span class="style4">COMID</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword1" id="txtKeyword1" value="<?=$_GET["txtKeyword1"];?>">
            </label></td>
          </tr>
        <tr>
          <td height="27"><div align="center"><span class="style4">COMSN</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword2" id="txtKeyword2" value="<?=$_GET["txtKeyword2"];?>"  />
            </label></td>
          </tr>
        <tr>
          <td height="27"><div align="center"><span class="style4">NAME</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword3" id="txtKeyword3"  value="<?=$_GET["txtKeyword3"];?>" />
            </label></td>
          </tr>
        <tr>
          <td height="28"><div align="center"><span class="style4">BRAND</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword4" id="txtKeyword4" value="<?=$_GET["txtKeyword4"];?>" />
            </label></td>
          </tr>
        <tr>
          <td height="26"><div align="center"><span class="style4">TYPE</span></div></td>
            <td colspan="3"><label>
              <input type="text" name="txtKeyword5" id="txtKeyword5" value="<?=$_GET["txtKeyword5"];?>" />
            </label></td>
          </tr>
        <tr>
          <td> </td>
            <td width="41"> </td>
            <td width="63"><label>
              <input type="submit" name="button" id="button" value="Serach" />
            </label></td>
            <td width="141"> </td>
          </tr>
        <tr>
          <td> </td>
            <td colspan="3"> </td>
          </tr>
        </table>
          </form></td>
        </tr>
      </table>
      
      <p> <hr width="150%"  style="border:0px;border-bottom:1px dashed #000" /></p>
      <p>
        <?php
 
	 mysql_connect($hostname_db_conn,$username_db_conn,$password_db_conn);  
    mysql_select_db($database_db_conn); 
	mysql_query('SET CHARACTER SET utf8');
	// Search By Name
	$strSQL = "SELECT  * FROM profilecomputer  WHERE ";
	 
	    if($_POST["txtKeyword1"] != "")
     {
         $strSQL .= " or (comID LIKE '%".$_POST["txtKeyword1"]."' ";
     }
	  if($_POST["txtKeyword2"] != "")
     {
         $strSQL .= " or (comSN LIKE '%".$_POST["txtKeyword2"]."' ";
     }
	  if($_POST["txtKeyword3"] != "")
     {
         $strSQL .= " or (ownTn LIKE '%".$_POST["txtKeyword3"]."' ";
     }
	  if($_POST["txtKeyword4"] != "")
     {
         $strSQL .= " or (Brand LIKE '%".$_POST["txtKeyword4"]."' ";
     }
	  if($_POST["txtKeyword5"] != "")
     {
         $strSQL .= " or (TYPE LIKE '%".$_POST["txtKeyword5"]."' ";
     }
	
 	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	echo mysql_error();
	$Num_Rows = mysql_num_rows($objQuery);


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

	?>
      </p>
      
      <table width="150%" border="1">
        <tr bgcolor="#00FFFF">
          <!--<th width="91"> <div align="center">CustomerID </div></th> -->
          <th width="20%"> <div align="center">comid</div></th>
	      <th width="14%"> <div align="center">comsn</div></th>
	      <th width="13%"> <div align="center">name</div></th>
          <th width="12%"> <div align="center">brand</div></th>
          <th width="14%"> <div align="center">type</div></th>
          <th width="12%"> <div align="center">Detail</div></th>
          <th width="7%"> <div align="center">Edit</div></th>
          <th width="8%"> <div align="center">Dlete</div></th>
        </tr>
        <?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
        <tr>
          <td height="23"><div align="center"><?=$objResult["comID"];?></div></td>
	      <td align="center"><?=$objResult["comSN"];?></td>
	      <td align="center"><?=$objResult["ownTn"];?></td>
   	        <td align="center"><?=$objResult["Brand"];?></td>
       	        <td align="center"><?=$objResult["TYPE"];?></td>
          <td align="center"><a href="detail.php?comID=<?=$objResult["comID"];?>">ดูรายละเอียด</a></td>
          <td align="center"><a href="formEdit.php?comID=<?=$objResult["comID"];?>">แก้ไข</a></td>
           <td align="center"><a href="Delete.php?comID=<?=$objResult["comID"];?>">Dlete</a></td>
        </tr>
        <?
	}
	?>
      </table>
      <br>
      จำนวนทั้งหมด 
      <?= $Num_Rows;?> 
      หน้า หน้าที่ : 
      <?=$Num_Pages;?> 
      หน้า :
    <?
	if($Prev_Page)
	{
		echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword1=$_GET[txtKeyword1]'><< Back</a> ";
	}

	for($i=1; $i<=$Num_Pages; $i++){
		if($i != $Page)
		{
			echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword1=$_GET[txtKeyword1]'>$i</a> ]";
		}
		else
		{
			echo "<b> $i </b>";
		}
	}
	if($Page!=$Num_Pages)
	{
		echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword1=$_GET[txtKeyword1]'>Next>></a> ";
	}
	
	mysql_close( );
 
	 	
	?>    </td> 
  </tr>
</table>
</body>
</html>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 15:45:57 By : thelak
 


 

No. 10



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

Code (PHP)
$strSQL = "SELECT  * FROM profilecomputer  WHERE 1 ";
if($_POST["txtKeyword1"] != "")
{
	$strSQL .= " AND ( comID LIKE '%".$_GET["txtKeyword1"]."%' or comSN LIKE '%".$_GET["txtKeyword1"]."%' or ownTn LIKE '%".$_GET["txtKeyword1"]."%' or Brand LIKE '%".$_GET["txtKeyword1"]."%' or  TYPE LIKE '%".$_GET["txtKeyword1"]."%'  )  "; 
}


แบบนี้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 16:06:19 By : webmaster
 


 

No. 11



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



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


Search
ตัวอย่าง form ในการค้นหาครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-04-20 17:30:08 By : thelak
 

   

ค้นหาข้อมูล


   
 

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