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 > รบกวนที่ครับ error แต่ไม่รุ้ว่า errorตรงไหนครับ โค้ดการค้นหาข้อมูลจาก mysql



 

รบกวนที่ครับ error แต่ไม่รุ้ว่า errorตรงไหนครับ โค้ดการค้นหาข้อมูลจาก mysql

 



Topic : 081551



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



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




ช่วยดูให้ทีครับ โค้ด ค้นหาข้อมูลจาก mysql


มันขึ้นประมาณเนี่ยอะครับ
from senior_n a left join senior_num b on a.p_numkey = b.p_numkey left join senior_adv c on a.p_adv = c.p_adv left join senior_sta d on a.p_sta_key = d.p_sta_key where (p_sta_key=)

Code (PHP)
<link href="/YUI/2.9/build/fonts/fonts-min.css" rel="stylesheet" type="text/css">
<link href="/YUI/2.9/build/menu/assets/skins/sam/menu.css" rel="stylesheet" type="text/css">
<script src="/YUI/2.9/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script>
<script src="/YUI/2.9/build/container/container_core-min.js" type="text/javascript"></script>
<script src="/YUI/2.9/build/menu/menu-min.js" type="text/javascript"></script>
<script src="/SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script><script src="/kaltura-html5player-widget/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/kaltura-html5player-widget/mwEmbed-player-static.js" type="text/javascript"></script>
<script type="text/xml">
<!--
<oa:widgets>
  <oa:widget wid="2567022" binding="#OAWidget" />
  <oa:widget wid="2294029" binding="#kalturaPlayer" />
</oa:widgets>
-->
</script>
<link href="/SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css">
<title>KUS:senior project</title>
<style type="text/css">
body {
	background-color: #CCC;
}
#apDiv1 {
	position:absolute;
	left:146px;
	top:335px;
	width:890px;
	height:191px;
	z-index:1;
}
</style>
<link href="/kaltura-html5player-widget/mwEmbed-player-static.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/* BeginOAWidget_Instance_2294029: #kalturaPlayer */

			@import url("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/redmond/jquery-ui.css");
		
/* EndOAWidget_Instance_2294029 */
a:link {
	color: #000;
	text-decoration: underline;
}
a:visited {
	text-decoration: underline;
	color: #999;
}
a:hover {
	text-decoration: underline;
	color: #609;
}
a:active {
	text-decoration: underline;
	color: #63C;
}
body,td,th {
	font-family: Tahoma, Geneva, sans-serif;
}
</style>
<table width="1005" border="1" align="center"  cellspacing=".5" bordercolorlight="#F0F0F0">
  <tr>
    <th width="999" nowrap><img src="/head.gif" width="1000" height="150"></th>
  </tr>
  <tr>
    <th nowrap bgcolor="#51256F"><style>
  .yui-skin-sam .yui-menu-shadow-visible {
	  background-color:#4f256b;
	  opacity:1;
	}
	
	.yui-menu-shadow-visible {
		top:2px;
		right:-3px;
		left:2px;
		bottom:-3px;
	}
	
	.yui-skin-sam .yuimenuitem-selected {
		background-color:#663399;
	}		
	
	.yui-skin-sam .yuimenuitemlabel {
		color:#000;
	}
	
	.yui-skin-sam .yuimenuitemlabel-disabled {
		color:#A6A6A6;
	}
	
	.yui-skin-sam .yuimenu {
		font-size:40px;
	}
	
	.yui-skin-sam .yuimenu .bd {
		background-color: #f0f0f0;
		border: solid 1px #666666;
	}	
  
  
    </style>
      <div id="OAWidget" class="yuimenubar yuimenubarnav">
        <div class="bd">
          <ul class="first-of-type">
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="http://senior-project-kus.orgfree.com/index.php">หน้าแรก</a>
            </li>
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="#search">ค้นหา</a>
            <div id="search" class="yuimenu">
            <div class="bd">
              <ul>
                <li class="yuimenuitem"><a class="yuimenuitemlabel" href="http://senior-project-kus.orgfree.com/search.php">ค้นหาผลงานโครงการศึกษาเฉพาะเรื่อง</a></li>
                <li class="yuimenuitem"><a class="yuimenuitemlabel" href="http://senior-project-kus.orgfree.com/search2.php">ค้นหาผลการอนุมัติการเสนอเรื่องโครงการศึกษาเฉพาะเรื่อง</a></li>
              </ul>
            </div>
          </div> </li>
           
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="http://158.108.70.5/seniorproject/manual.pdf" target="_blank">คู่มือโครงการ</a>
            </li>
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="http://158.108.70.5/seniorproject/map1.pdf" target="_blank">แผนดำเนินงานสำหรับนักเรียน</a>
            </li>
            <li class="yuimenubaritem first-of-type"><a href="http://158.108.70.5/seniorproject/sample1.pdf" target="_blank" class="yuimenubaritemlabel">ตัวอย่างงาน Senior Project</a>
            </li>
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="http://158.108.70.5/seniorproject/seniorprojectassessment.pdf" target="_blank">ผลประเมินโครงการของนักเรียน</a>
            </li>
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="#name">รายนาม</a>
            <div id="name" class="yuimenu">
            <div class="bd">
              <ul>
                <li class="yuimenuitem"><a class="yuimenuitemlabel" href="http://158.108.70.5/seniorproject/parent.htm">รายนามอาจารย์</a></li>
                <li class="yuimenuitem"><a class="yuimenuitemlabel" href="http://158.108.70.5/seniorproject/teacher.htm">รายนามผู้เชี่ยวชาญ</a></li>
              </ul>
            </div>
          </div> </li>
            <li class="yuimenubaritem first-of-type"><a class="yuimenubaritemlabel" href="http://senior-project-kus.orgfree.com/admin.php" target="_blank" >สำหรับผู้ดูแล</a>
            </li>
          </ul>
        </div>
      </div>
    <script type="text/javascript">
// BeginOAWidget_Instance_2567022: #OAWidget
 
(function() { 
  var cn = document.body.className.toString();
  if (cn.indexOf('yui-skin-sam') == -1) {
    document.body.className += " yui-skin-sam";
  }
})();

var initOAWidget = function() {
  /*
       Instantiate a Menu:  The first argument passed to the 
       constructor is the id of the element in the page 
       representing the Menu; the second is an object literal 
       of configuration properties.
  */

  var OAWidget = new YAHOO.widget.MenuBar("OAWidget",  { autosubmenudisplay: true, lazyload: true } );
    
  OAWidget.render();
};

// Create the YUI Menu when the HTML document is usable.
YAHOO.util.Event.onDOMReady(initOAWidget);

// EndOAWidget_Instance_2567022
      </script></th>
  </tr>
  <tr>
    <td height="156" bgcolor="#FFFFFF"><table width="93%" align="center">
      <tr>
        <td height="302" nowrap="nowrap"><form action="<?=$_SERVER['SCRIPT_NAME'];?>" method="get" name="frmSearch" id="frmSearch">
          <table width="60%"align="center" >
            <tr>
              <td height="69"><div align="center"><strong>ระบบสารสนเทศโครงการศึกษาเฉพาะเรื่องจัดทำเพื่อใช้สืบค้นระบบฐานข้อมูล</strong></div>
                <hr />
                <div>
                  <blockquote>
                    <p>ผลการอนุมัติการเสนอเรื่องโครงการศึกษาเฉพาะเรื่อง <br />โดยสืบค้นจาก ; ชื่อเรื่อง, ชื่ออาจารย์ที่ปรึกษา,ชื่อนักเรียน, <br />ผลการดำเนินงาน (รออนุมัติ, ผ่าน, ไม่ผ่าน) </p>
</blockquote>
                </div></td>
            </tr>
          </table>
          <table width="598" align="center">
            <tr>
              <th width="590"><p>คำค้น
                <input name="keyword" type="text" id="keyword" value="<?=$_GET["txtKeyword"];?>" size="50" />
                
                <label> 
                  <br />
                  <input type="checkbox" name="status[]" value="5" id="status_5" />
                  เสร็จสิ้น</label>
               
                <label>
                  <input type="checkbox" name="status[]" value="1" id="status_1" />
                  รอผลการอนุมัติ</label>
                
                
                  <label>
                    <input type="checkbox" name="status[]" value="2" id="status_2" />
                    ผ่าน</label>
                  
                  <label>
                    <input type="checkbox" name="status[]" value="3" id="status_3" />
                    ไม่ผ่าน</label>
                  
                  <label>
                    <input type="checkbox" name="status[]" value="4" id="status_4" />
                    รอสอบ</label> 
                  <input type="submit" value="Search" />
                  
                </p></th>
            </tr>
          </table>
        </form>
        <?
for($i=0;$i<count($_get["status"]);$i++)
{
	if(trim($_get["status"][$i]) != "")
	{
		echo "status $i = ".$_get["status"][$i]."<br>";
	}
}
?>
          <?
		  
		 $keyword = $_GET["txtKeyword"] ; 
		  
		  {
		  include("connect.php");
$arr_search_condition = (array) null;
$arr_search_condition[] = "(p_sta_key=".$_get["status"][$i].")";

if(trim($keyword)) 		$arr_search_condition[] = "( p_id LIKE '%$keyword%'|| p_stu_fname LIKE '$%keyword%' || p_stu_sname LIKE '%$keyword%' || p_adv_fname LIKE '%$keyword%' || p_adv_sname LIKE '%$keyword%'  )" ;
	
	$search_condition = "";
	if(count($arr_search_condition)) $search_condition = " where ".implode(" and ", $arr_search_condition);
	
	$sql = " select a.* ,b.p_num,c.p_adv_num , c.p_adv_fname , c.p_adv_sname, d.p_sta from senior_n a 
	
left join senior_num b on a.p_numkey = b.p_numkey	
left join senior_adv c on a.p_adv = c.p_adv
left join senior_sta d on a.p_sta_key = d.p_sta_key 
$search_condition";
	
	
	$objQuery = mysql_query($sql) or die ("Error Query [".$sql."]");
	$Num_Rows = mysql_num_rows($objQuery);


	$Per_Page = 30;   // 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 p_id ASC LIMIT $Page_Start , $Per_Page";
	$objQuery  = mysql_query($sql);

		  }
	?>
          <table width="819" border="1" align="center" class="square">
            <tr bgcolor="#551B6D"  style="color:#FFF;">
              <td width="50" height="85" align="center"><strong>รหัส</strong></td>
              <td width="292" align="center"><strong>ชื่อ Senior Project</strong></td>
              <td width="180" align="center"><strong>ชื่อนักเรียน</strong></td>
              <td width="170" align="center"><strong>ชื่ออาจารย์ที่ปรึกษา</strong></td>
              <td width="93" align="center"><strong>ผลการอนุมัติ</strong></td>
              </tr>
            <?

$Num_Rows = 0;
while($objResult = mysql_fetch_array($objQuery)) {
$Num_Rows++;

if ($Num_Rows % 2 == 0){
?>
<tr bgcolor="#E9C8FB"   >
<? 
} else {
?>
<tr bgcolor="#FFFFFF">
<?
}
?>
<td><div align="center"><?=$objResult["p_id"]?> </div></td>
<td><div align="left"><?=$objResult["p_name"];?></div></td>
<td><div align="left">
                  <?=$objResult["p_num"];?>
                <?=$objResult["p_stu_fname"];?>
                <?=$objResult["p_stu_sname"];?>
                </div></td>
<td><div align="left">
                <?=$objResult["p_adv_num"];?>
                <?=$objResult["p_adv_fname"];?>
                <?=$objResult["p_adv_sname"];?>
              </div></td>
              <td><div align="center">
                <?=$objResult["p_sta"]; ?>
              </div></td>
              </tr>
<?
}
?>
          </table>
          <br />
          ผลการค้นหาทั้งหมด
          <?= $Num_Rows;?>
มีหน้าทั้งหมด :
<?=$Num_Pages;?>
หน้า :
<?
	if($Prev_Page)
	{
		echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><<หน้าก่อนหน้า</a> ";
	}

	for($i=1; $i<=$Num_Pages; $i++){
		if($i != $Page)
		{
			echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
		}
		else
		{
			echo "<b> $i </b>";
		}
	}
	if($Page!=$Num_Pages)
	{
		echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>หน้าถัดไป>></a> ";
	}
	
	mysql_close();

		
	?></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <th height="154" nowrap><img src="/down.gif" width="1000" height="150"></th>
  </tr>
</table>





Tag : PHP, MySQL, JavaScript, Action Script, jQuery







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-07-25 23:25:15 By : crazydrogon View : 1121 Reply : 4
 

 

No. 1



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

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

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


บรรทัดที่ 235 - 239
Code (PHP)
select a.* ,b.p_num,c.p_adv_num , c.p_adv_fname , c.p_adv_sname, d.p_sta from senior_n a
left join senior_num b on a.p_numkey = b.p_numkey  
left join senior_adv c on a.p_adv = c.p_adv
left join senior_sta d on a.p_sta_key = d.p_sta_key

//ตย.จากในเว็บ https://www.thaicreate.com/tutorial/sql-left-join.html
SELECT audit.* FROM customer
LEFT JOIN audit ON customer.CustomerID = audit.CustomerID 
WHERE customer.CustomerID = 'C001'



ผมก็ไม่แน่ใจว่าผิดตรงไหนนะ แต่ดูคิวรี่ของคุณมันแปลก ๆ ไงไม่รู้ เช่น senior_n a คืออะไร

https://www.thaicreate.com/php/forum/032709.html






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-26 05:06:14 By : apisitp
 


 

No. 2



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



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


Senior_n เป็นชื่อตารางครับ โดยจะเก็บคียจาก ตารางอื่น ก่อนหน้าขี้ผมใช่ได้ปกริไม่ปัญหาอไม่รู
แต่ใช่คำสั่งโดยตรงเลย แต่อันนี้ลองใชเป็นตัวแปร array มาด้วย
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-26 15:12:39 By : crazydrogon
 

 

No. 3



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

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

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


อันนี้ผมไม่รู้จริง ๆ ไม่เคยใช้ ก็เลยไปเปิดรูปแบบดูจากกระทู้เก่า ๆ ผมผเลยมาถามว่า senior_n a คืออะไร
คุณ CRAZY MAN บอกว่า Senior_n เป็นชื่อตารางครับอันนี้ผมเข้าใจ
แต่ที่ผมว่ามันแปลกอักษร a ที่เหลือมันมาห้อยลอย ๆ แบบนั้นผมพยายามดูคำสั่ง ทำความเข้าใจ แต่ก็ไม่เข้าใจ
ผมก็มือใหม่สงสัยเลยถามเพราะอยากรู้ แต่ถ้าคุณ CRAZY MAN ว่าก่อนหน้านี้ใช้ได้ปกติก็คงเป็นตามนั้นล่ะ รอเทพ ๆ ต่อไป
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-26 17:08:03 By : apisitp
 


 

No. 4



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



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


คล้ายเป็นตัวเทียบอะครับ ว่าข้อมูลนี้อยู่อีกตารางหนึ่ง เหมือนตัรเท่ากับ ตาราง.ตามด้วยชื่อ ฟิล แล้วเอาค่าจาก aมาเทียบกับตารางอื่น ที่เราต้อง ประมาณนั้นอะครับอธิบายไม่ถูกเหมือนกัน
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-07-26 18:07:07 By : crazydrogon
 

   

ค้นหาข้อมูล


   
 

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