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 : 080726

Guest




Code (PHP)
<?php
include "chksession.php";  //check login 
include "header.php";
include "connect.php";
  
  
		$sql = "select * from suite";		
		if($_POST['type']  !="" && $_POST['keyword'] !=""){
		$type=$_POST['type'];
		$keyword=$_POST['keyword'];
		$sql .=" Where  $type like '%$keyword%' ";
		}
		$result  = mysql_query($sql);
		$nrowpage = mysql_num_rows($result);
		
		//แบ่งหน้า
		$list_page = 10; if (empty($page)) { $page=1; }
		$rt = $nrowpage%$list_page;
		if($rt != 0) { $totalpage = floor($nrowpage/$list_page)+1; } else { $totalpage = floor($nrowpage/$list_page); } 
		$goto = ($page-1)*$list_page;
		$sql .= " limit $goto, $list_page ";
		$rst=mysql_query($sql);	
		
		?>
<table width="1000" border="0" align="center" bgcolor="#FFFFFF">
<tr>
            <td width="10%" height="23" align="left" valign="top" bgcolor="#FF99FF"><?php include "menu1.php";?></td>
<td valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center">
      <tr>
        <td height="744" align="left" valign="top"><p>
        
        <center>
        </center>
	</center>
	
	<table width="90%" border="0" align="center">
      <tr>
        <td align="center"><form id="form1" name="form1" method="post" action="<? $PHP_SELF ?>">
            <table width="78%" border="0">
              <tr>
                <td height="191" align="left"><fieldset>
                  <legend><strong>ค้นหาข้อมูลลูกค้า</strong></legend>
                  <p>&nbsp;</p>
                  <center>
                    <table width="100%" border="0">
                      <tr>
                        <td width="20%" align="left" nowrap="nowrap"><strong>ใส่คำค้นหา : </strong></td>
                        <td width="19%" align="left"><label>
                          <select name="type" id="type">
                            <option value="">---เลือก---</option>
                            <option value="type_name">ประเภทชุด</option>
                            <option value="suite_name">ชื่อชุด</option>
                            <option value="suite_size">ขนาดชุด</option>
                          </select>
                          </label>
                        </td>
                        <td width="20%" align="left" nowrap="nowrap"><strong>รายละเอียด :</strong></td>
                        <td width="29%" align="left"><input type="text" name="keyword" id="keyword" /></td>
                        <td width="12%" align="left"><input type="submit" name="button" id="button" value="ค้นหา" /></td>
                      </tr>
                    </table>
                    <p>&nbsp;</p>
                  </center>
                </fieldset></td>
              </tr>
            </table>
        </form></td>
      </tr>
    </table>
	<p>&nbsp;</p>
	<p align="center"><strong>จัดการข้อมูลชุด</strong><br>
	  </p>
	<center>
        
        <table width ="100%" border="0" align="center" cellpadding ="0" cellspacing ="1" bordercolor="#999999" bgcolor="#999999">
		<input type ="hidden"  name = "method"  value="<?php echo $method;?>"/>
		<tr bgcolor="#CC99FF">
		  <th align="center" bgcolor="#FF66CC">ลำดับ</th>
          <th align="center" bgcolor="#FF66CC">ประเภทชุด</th>
          <th align="center" bgcolor="#FF66CC">ชื่อชุด</th>
          <th align="center" bgcolor="#FF66CC">ขนาดชุด</th>
          <th align="center" bgcolor="#FF66CC">ราคาเช่าชุด</th>
		  <th align="center" bgcolor="#FF66CC">ราคาตัด</th>
          <th align="center" bgcolor="#FF66CC">จำนวนชุด</th>
		  <th align="center" bgcolor="#FF66CC">จัดการ	</th>
		</tr>

	
	<?php
	$color = "#BBF1FF";
			$result  = mysql_query($sql);
			while($row = mysql_fetch_array($result)) {
				 
				 $start++;
				 $type_id=$row['type_id'];
				 $suite_id=$row['suite_id'];
				 $suite_name=$row['suite_name'];
				 $suite_size=$row['suite_size'];
				 $suite_detail=$row['suite_detail'];
				 $suite_price_rent=$row['suite_price_rent'];
				 $suite_price_cut=$row['suite_price_cut'];
				 $suite_price_extra=$row['suite_price_extra'];
				 $suite_image=$row['suite_image'];
				 $suite_amount=$row['suite_amount'];
				
				$sql2="select * from suite_type where type_id='$type_id'";
							$result2 = mysql_query($sql2,$link);
							$row2 = mysql_fetch_array($result2);
							$type_name=$row2['type_name'];
				//ฟังก์ชันสลับสีแสดงผล
				if($color=="#FFCCFF"){
					$color="#FFFFFF";
					}else{
					$color="#FFCCFF";
				
					}
					/////////////////////////////////////////////////
					echo "<tr bgcolor=\"$color\" align=center>";
					echo "<td align='center'>$start</td>";
					echo "<td align='center'>$type_name</td>";
					echo "<td align='center'>$suite_name</td>";
					echo "<td align='center'>$suite_size</td>";
					echo "<td align='center'>$suite_price_rent</td>";
					echo "<td align='center'>$suite_price_cut</td>";
					echo "<td align='center'>$suite_amount</td>";
				
					
					
					echo "<td><a href=\"./frm_edit.php?suite_id=$suite_id\">แก้ไข</a> <a href=\"./delete_suite.php?method=delete&suite_id=$suite_id\" onClick=\"var x=confirm('ลบรายการนี้ทันที'); if (!x) return false;\">
					ลบ</a></td>";
					echo "</tr>";
			}
		?>
		
		<tr align="center" bgcolor="#CCCCCC" height="2">
			<td colspan="7" valign="top"></td>
		</tr>
		</table></center>
		<p align="center">
		  <?
   		for($i=1 ; $i<$page ; $i++) {
		print "<a href='$PHP_SELF?type=$type&keyword=$keyword&page=$i'>$i</a> "; }
		print "<font size='3' color='#000000'><b>[$page]</b></font> ";
		for($i=$page+1 ; $i<=$totalpage ; $i++) {
		print "<a href='$PHP_SELF?type=$type&keyword=$keyword&page=$i'>$i</a> "; }
	?>
		</p>
    <p align="center">ทั้งหมด <strong>
    <?=$nrowpage?>
    </strong> รายการ <br>
                </p>
		<center></td>
      </tr>
    </table></td>
  </tr>
</table>
</td>
</tr>

<? include "footer.php"; ?>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-07-08 00:28:08 By : kam View : 806 Reply : 2
 

 

No. 1



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



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


ลอง echo คำสั่ง SQL ออกมา แล้วไปแปะใน phpMyAdmin ดูครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 02:02:39 By : Pine
 


 

No. 2



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

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

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

Code (PHP)
$rst=mysql_query($sql) or die(mysql_error());	

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-08 06:34:20 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
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 00
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 อัตราราคา คลิกที่นี่