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 > รบกวนพี่ครับ ผมใช้การ join ตาราง 2 ตารางครับเพื่อดึงค่าออกมาแต่ มันขึ้น ERROR ครับ ดูข้างในนะครับ



 

รบกวนพี่ครับ ผมใช้การ join ตาราง 2 ตารางครับเพื่อดึงค่าออกมาแต่ มันขึ้น ERROR ครับ ดูข้างในนะครับ

 



Topic : 115125



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



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



รบกวนพี่ครับ ผมใช้การ join ตาราง 2 ตารางครับเพื่อดึงค่าออกมาแต่ มันขึ้น ERROR ครับ
รูปครับ

error ครับ

Code (PHP)
<a href="./?P=Member">จัดการคืนสินค้า</a> / 



<!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>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="50">&nbsp;</td>
      <td width="250"><div align="right">เลือกสถานะการคืนสินค้า:_</div></td>
      <td width="300"><label>
        <select name="search" id="search">
          <option value="#">**เลือกสถานะสินค้า**</option>
          <option value="1">ไม่คืนสินค้า</option>
          <option value="2">คืนสินค้า</option>
        </select>
        <input type="submit" name="Submit" id="button" value="ค้นหา" />
      </label></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p>
  <?php 
  include"config.inc.php";
  include"db/functiondate.php";
  $con = mysql_connect($host,$username,$password);
if (!$con)
  {     die('Could not connect: ' . mysql_error());    }
  mysql_select_db($database, $con);
  mysql_query("SET NAMES UTF8");
  $search=$_REQUEST['search'];

//////////////////////////////////////////////////////////////ตรงนี้เลยครับที่น่าจะมีปัญหา//////////////////////////////////////////////////////////////////////////
  
		  if($_POST['search']=="#"){		
			$sql="select orders.*,order_detail.* from(orders inner join order_detail on orders.order_id=order_detail.order_id)";
		  }else{
			//$sql="select * from order_detail where order_detail.de_status like '$_POST[search]%'";
		$sql="select orders.*,order_detail.* from(orders inner join order_detail on orders.order_id=order_detail.order_id) where order_detail.de_status like '$_POST[search]%'";
		  }
	$result = mysql_query($sql);
	$Num_Rows=mysql_num_rows($result);
	$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;
	}
	$sql .=" order  by order_id DESC LIMIT $Page_Start , $Per_Page";
	$result  = mysql_query($sql);
	if($Num_Rows==0){
		echo"<br><center><font color='red'>ไม่พบรายการสินค้า $_POST[search] </font></center>";
	}else{
	?>
</p>
สินค้าทั้งหมดมี&nbsp;<?php echo"$Num_Rows"; ?>&nbsp;รายการ
<table width="100%" border="1" align="center" cellpadding="5" cellspacing="0" bgcolor="#CCCCCC">
  <tr style="color:#FFF;">
    <td width="64" align="center" bgcolor="#666666"><strong>รหัสใบออร์เดอร์</strong></td>
    <td width="90" align="center" bgcolor="#666666"><strong>รหัสสินค้า</strong></td>
    <td width="93" align="center" bgcolor="#666666"><strong>ชื่อสินค้า</strong></td>
    <td width="93" align="center" bgcolor="#666666"><strong>วันที่สั่งสินค้า</strong></td>
    <td width="115" align="center" bgcolor="#666666"><strong>ราคาต่อหน่วย</strong></td>
    <td width="89" align="center" bgcolor="#666666"><strong>จำนวนสินค้า</strong></td>
    <td width="104" align="center" bgcolor="#666666"><strong>ต้นทุนรวม</strong></td>
    <td width="156" align="center" bgcolor="#666666"><strong>แจ้งเตือน</strong></td>
    <td width="67" align="center" bgcolor="#666666"><strong>สถานะสินค้า</strong></td>
    <td width="101" align="center" bgcolor="#666666"><strong>จัดการข้อมูล</strong></td>
  </tr>
  <?php
		$no=1;
		while($row3=mysql_fetch_array($result)){
		$order_id=$row3[order_id];
			  $id_pro=$row3[id_pro];
			  $price_unit=$row3[price_unit];
			  $quantity=$row3[quantity];
              $name_pro=$row3[name_pro]; 
			  $product_on_hand=$row3[product_on_hand];
			  $order_date=$row3[order_date];
			  $de_order=$row3[de_order];
			if($bg=="#FFFFFF"){
				$bg="#F8F8F8";
			}else{
				$bg="#FFFFFF";
			}
			?>
  <tr  bgcolor="<?php echo"$bg"; ?>">
    <td height="24" align="center"><?php echo"$order_id"; ?></td>
    <td align="center" valign="middle" bgcolor="<?php echo"$bg"; ?>"><?php echo"$id_pro"; ?><br /></td>
   
    <td align="left">
     <?php 
	$sql2="select products.*,order_detail.* from(products inner join order_detail on products.id_pro=order_detail.id_pro)";
	$result2=mysql_query($sql2);
	while($read1=mysql_fetch_array($result2)){
	$id_pro=$read1[id_pro];
	$name_pro=$read1[name_pro];
	?>
	
	<?php 
	if($row3['id_pro']==$read1['id_pro']){
	echo"$name_pro"; 
}else{
}
?>
<? }?>
</td>
    
    <td align="center"><span style="border-bottom:#F90 dashed 1px">
      
	  <? echo"$order_date";?>
	  <? $strDate = "$order_date";echo "".DateThai($strDate); ?>
    </span></td>
    <td align="right"><?php echo"".number_format($price_unit).""; ?> บาท</td>
    <td align="right"><?php echo"$product_on_hand"; ?> หน่วย</td>
    <td align="center"><? echo"$total_cost";?>&nbsp;</td>
    <td align="center"><?php 
		  	if($product_on_hand==0){
			?>
      <font color="red">สินค้าหมด !</font>
      <?php 
			}else if($product_on_hand<=5){
			?>
      <font color="red">สินค้าใกล้หมด !</font>
      <? }else if($product_on_hand>=5){
			?>
      <font color="blue">สินค้ามีอยู่</font>
      <?php } ?></td>
    <td align="center"><? echo"$n_status";?>&nbsp;</td>
    <td align="center">[<a href="./?P=Product&amp;status=stock&amp;id_pro=<?php echo"$id_pro"; ?>">สต็อก</a>][<a href="./?P=Product&amp;status=edit&amp;id_pro=<?php echo"$id_pro"; ?>">แก้ไข</a>][<a href="product_delete.php?id_pro=<?php echo"$id_pro"; ?>" onclick="return confirm('ท่านต้องการจะลบข้อมูลออกจากระบบหรือไม่')">ลบ</a>]</td>
  </tr>
  <?php
		$no++;
		}
		?>
</table>
ทั้งหมด <?php echo"$Num_Rows"; ?> รายการ : <?php echo"$Num_Pages"; ?> หน้า :
<?php
if($Prev_Page){
	echo " <a href='?P=Member&Page=$Prev_Page'><< ก่อนหน้า</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){

if($i != $Page)

{

echo "[ <a href='?P=Product&Page=$i'>$i</a> ]";

}

else

{

echo "<b> $i </b>";

}

}

if($Page!=$Num_Pages)

{

echo " <a href ='?P=Product&Page=$Next_Page'>ถัดไป >></a> ";

}

?>
<?php  } ?>
</body>
</html>




Tag : PHP









ประวัติการแก้ไข
2015-03-16 01:26:57
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-03-16 01:25:18 By : hoyahoya View : 589 Reply : 2
 

 

No. 1



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



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


Code
$sql .=" order by orders.order_id DESC LIMIT $Page_Start , $Per_Page";







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-16 01:53:02 By : sabaitip
 


 

No. 2



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



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

ออกแล้วครับ ขอบพระคุณมากครับ พี่ Cop
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-03-16 01:57:18 By : hoyahoya
 

   

ค้นหาข้อมูล


   
 

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