|  |  | 
          
            | คือผมจะให้มันโชว์ ข้อมูล ตามหัวข้อที่เลือก ทั้งหมดอะคับ แต่ข้อมูลที่โชว์ กลับแสดงแค่รายการเดียว จริงๆ มันต้อมี 2 รายการอะครับ ตามภาพเลยครับ รบกวนหน่อยคับ ผมแก้มาหลายรอบแล้ว  
 คือในภาพครับ ในตารางกรอบสีแดง ต้องมีมากกว่า 1 รายการอะครับ
 
  
 
 โค้ดตอนเลือกรายการข้อมูลคับ
 
 <?
	mysql_connect("localhost","root","1111") or die(mysql_error());
	mysql_select_db("newproject");
?>
<script type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<form action="show_ready.php" method="post" name="frmMain">
  รายการโปรเจค
  <select name="lmName1" OnChange="window.location='?item='+this.value;">
			<option value=""><-- Please Select Item --></option>
			<?
			$strSQL = "SELECT * FROM project ORDER BY id_project ASC";
			$objQuery = mysql_query($strSQL);
			while($objResult = mysql_fetch_array($objQuery))
			{
				if($_GET["item"] == $objResult["id_project"])
				{
					$sel = "selected";
				}
				else
				{
					$sel = "";
				}
			?>
			<option value="<?=$objResult["id_project"];?>" <?=$sel;?>><?=$objResult["id_project"];?></option>
			<?
			}
			?>
		  </select>
		  <?
		  if($_GET["item"] != "")
		  {
			$strSQL = "SELECT * FROM project WHERE id_project = '".$_GET["item"]."' ";
			$objQuery = mysql_query($strSQL);
			$objResult2 = mysql_fetch_array($objQuery);
			 }
			
		  ?>
			 
	
	<input type="hidden" name="hdnLine" value="<?=$objResult2["Nproject"];?>">
	<input type="hidden" name="hdnLine2" value="<?=$objResult2["year"];?>">
	<input type="hidden" name="hdnLine3" value="<?=$objResult2["priceLM"];?>">
	<input type="hidden" name="hdnLine4" value="<?=$objResult2["Norg"];?>">
	<input type="hidden" name="item" value= "<?=$_GET["item"]; ?> ">
	
		 <?
		
		  if($_GET["item"] != "")
		  	{
			$strSQL = "SELECT  company.Ncompany, product.Nproduct,pro_comp.price,product.middleprice
					   From	present, product, company,pro_comp
			           WHERE company.id_company = present.id_company
						AND product.id_product = present.id_product
						AND pro_comp.id_product=present.id_product
						AND pro_comp.id_company=present.id_company
						and present.id_project = '".$_GET['item']."' ";
			$objQuery = mysql_query($strSQL);
			$objResult2 = mysql_fetch_array($objQuery);
			$num_rows = mysql_num_rows($objQuery);
			
			
		  }
		 	
		   ?>
		  <input type="hidden" name="hdnLine5" value="<?=$objResult2["Nproduct"];?>">
		  <input type="hidden" name="hdnLine6" value="<?=$objResult2["Ncompany"];?>">
		  <input type="hidden" name="hdnLine7" value="<?=$objResult2["price"];?>">
		  <input type="hidden" name="hdnLine8" value="<?=$objResult2["price"];?>">
		   
    
    <label>
    <input type="submit" name="Submit" value="เลือก" />
    </label>
	
</form>
	
	
</body>
</html>
<?
	mysql_close();
?>
 
 โค้ด ตอนแสดงข้อมูลลครับ
 
 <? 	mysql_connect("localhost","root","1111") or die (mysql_error());
    mysql_select_db("newproject");
	mysql_query("set names utf8");
	mysql_query("SET character_set_results=utf8");
	mysql_query("SET character_set_client=utf8");
	mysql_query("SET character_set_connection=utf8");
?>
<body>
<table width="577" border="1" align="center">
  <tr>
    <th colspan="4" scope="row"> 
		
		<?	   echo $_POST["hdnLine"];  ?>	</th>
  </tr>
  <tr>
    <th colspan="3" scope="row">งบประมาณรายจ่ายประจำปีงบประมาณ</th>
  <td width="144"> 
  		<? if($_POST["hdnLine2"]=="1" )
			{echo "พ.ศ.2555";} 
			else if ($_POST["hdnLine2"]=="2")
		    {echo "พ.ศ.2554";} 
		?>  </tr>
  <tr>
    <th width="156" scope="row">วงเงิน</th>
    <th width="117" scope="row">
		<? echo $_POST["hdnLine3"]; ?>
	</th>
    <th colspan="2" scope="row">
		<? echo $_POST["hdnLine4"];  ?>
	</th>
  </tr>
</table>
<p> </p>
<form id="form1" name="form1" method="post" action="">
  <table width="1122" border="1" align="center">
  
    <tr> 
	
      <th width="55" scope="row"><div align="center" class="style1">        ลำดับ</div></th>
      <td width="431"><div align="center" class="style1">        รายการ</div></td>
      <td colspan="3"><div align="center" class="style1">        เปรียบเทียบ 3 รายการ </div></td>
      <td width="116"><div align="center" class="style1">        ราคาจัดหา</div></td>
    </tr>
    <tr>
      <th rowspan="2" scope="row"> </th>
      <td rowspan="2"><? echo $_POST["hdnLine5"]; ?></td>
      <td><? echo $_POST["hdnLine6"]; ?></td>
      <td> </td>
      <td> </td>
      <td rowspan="2"><? echo $_POST["hdnLine8"]; ?></td>
    </tr>
    <tr>
      <td width="200"><? echo $_POST["hdnLine7"]; ?></td>
      <td width="200"> </td>
      <td width="200"> </td>
    </tr>
  </table>
</form>
<p> </p>
</body>
</html>
<? 
	mysql_close();
?>
 
 
 Tag : PHP, MySQL
 
 
 |  
            | 
 ประวัติการแก้ไข
 2012-05-22 10:12:36
 |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2012-05-22 10:11:29 | By :
                          GUNdum | View :
                          1174 | Reply :
                          6 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |