เมื่อคลิกเลือกที่dropdownlist แล้วให้แสดงข้อมูลตาม dropdown ทำยังไงได้บ้าง

กระทู้คำถาม
โค๊ดที่ใช้อยู่ก็ดูมาตามเน็ตค่ะ ไม่รุ้ว่าต้องทำยังไง ไม่ค่อยมีความรู้เลยค่ะ รบกวนสอบถามค่ะ
<!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>
<?php
    function timeplus($arr)
    {
        $hour = 0;
        $minute = 0;
        $second = 0;
        foreach ($arr as $value)
        {
            $arrtime = explode(":", ":", $value);            
            $hour += $arrtime[0];
            $minute += $arrtime[1];
            $second += $arrtime[2];            
        }
        return ($hour + floor($minute / 60)) . ":". str_pad(($minute %60), 2, "0" , STR_PAD_LEFT). ":". str_pad(($second % 60), 2, "0" , STR_PAD_LEFT);
    }
?>
<?php
     $_POST['unit'] ;
  $_POST['month'] ;
   $_POST['year'] ;
include"database.php";
$objDB = mysql_select_db("bpk");
    $strSQL = "SELECT * FROM outageevent  ";
    $objQuery = mysql_query($strSQL) or die ("Error Query");
     if($_POST['unit']==0 && $_POST['month']==0 && $_POST['year']==0){
}else{//เมื่อมีการเลือกเงื่อนไข
$sql= "select * from outageevent where year and month and unit"; //ก็ต้องมี where

if($_POST['unit']!="0" && $_POST['month']!="0" && $_POST['year']!="0"){
$sql.= "unit='".$_POST['unit']."' and month='".$_POST['month']."' and year='".$_POST['year']."'";
}else if($_POST['unit']!="0" && $_POST['month']!="0" && $_POST['year']=="0"){
$sql.= "unit='".$_POST['unit']."' and month='".$_POST['month']."'";
}else if($_POST['unit']!="0" && $_POST['month']=="0" && $_POST['year']!="0"){
$sql.= "unit='".$_POST['unit']."' and year='".$_POST['year']."'";
}

}
    $Num_Rows = mysql_num_rows($objQuery);
    $Per_Page = 50;   // 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 hour desc LIMIT  $Page_Start , $Per_Page";
$objQuery  = mysql_query($strSQL);
    ?>
<body>
<form name="frmSearch" method="post" action=" ">
  <table width="840" border="1">
    <tr>
      <th width="830">Select
        <select name="unit">
          <option value="&lt;--  Select Unit --&gt;">&lt;--  Select Unit --&gt;</option>
          <?php
            $select = "SELECT DISTINCT unit FROM outageevent ";
            $objfrom = mysql_query($select);
            while($objResult = mysql_fetch_array($objfrom))
            {
                if($strDefault == $objResult["unit"])
                {
                    $sel = "selected";
                }
                ?>
          <option value="<?php echo $objResult["unit"];?>" <?php echo $sel;?>><?php echo $objResult["unit"];?></option>
          <?php
            }
            ?>
        </select>
        <select name="month">
          <option value="&lt;--  Select month --&gt;">&lt;--  Select month --&gt;</option>
          <?php
    $sql = "SELECT DISTINCT month FROM outageevent  ";
    $qry= mysql_query($sql) or die(mysql_error());
    while($rs = mysql_fetch_array($qry)){
?>
          <option value="<? echo($rs["month"]);?>"><? echo($rs["month"]);?></option>
          <? } ?>
        </select>
        <select name="year">
          <option value="&lt;-- Select Year --&gt;">&lt;-- Select Year --&gt;</option>
          <?php
    $sql = "SELECT DISTINCT year FROM outageevent  ";
    $qry= mysql_query($sql) or die(mysql_error());
    while($rs = mysql_fetch_array($qry)){
?>
          <option value="<? echo($rs["year"]);?>"><? echo($rs["year"]);?></option>
          <? } ?>
        </select>
        <input type="submit" value="Search" />  
      
    </tr>
  </table>
  <table width="50%" border="0" align="center">
        <tr>
          <td><a href="index.php">event ทั้งหมด</a></td>
          <td><a href="top10.php">top 10 ชั่วโมงสูญเสีย</a></td>
          <td><a href="count.php">ตารางสรุปจำนวน</a></td>
          <td><a href="tool.php">ตารางสรุปอุปกรณ์</a></td>
      
    </tr>
  </table>
</form>

    <table width="100%" height="70" border="1">
<tr bgcolor="#00FF00">
<th width="72"> <div align="center"> ลำดับ</div></th>
<th width="72"> <div align="center"> YEAR</div></th>
<th width="51"> <div align="center">MONTH </div></th>
<th width="51"> <div align="center">UNIT </div></th>
<th width="309"> <div align="center">EVENT </div></th>
<th width="69"> <div align="center">START DATE </div></th>
<th width="61"> <div align="center">START TIME </div></th>
<th width="59"> <div align="center">END DATE </div></th>
<th width="61"> <div align="center">END TIME </div></th>
<th width="74"> <div align="center">HOUR</div></th>
<th width="73"> <div align="center">TYPE</div></th>
<th width="71"> <div align="center">NET MW </div></th>
<th width="83"> <div align="center">MW LOSS</div></th>
</tr>

    <?
    $a=1;
    while($objResult = mysql_fetch_array($objQuery))
    {
    ?>
     <tr>
<td><div align="left"><?php echo $a;?></div></td>
<td><div align="left"><?=$objResult["year"];?></div></td>
<td><?=$objResult["month"];?></td>
<td><?=$objResult["unit"];?></td>
<td><div align="left"><?=$objResult["event"];?></div></td>
<td align="right"><?=$objResult["sdate"];?></td>
<td align="right"><?=$objResult["stime"];?></td>
<td align="right"><?=$objResult["edate"];?></td>
<td align="right"><?=$objResult["etime"];?></td>
<td align="right"><?=$objResult["hour"];?></td>
<td align="right"><?=$objResult["etype"];?></td>
<td align="right"><?=$objResult["netmw"];?></td>
<td align="right"><?=$objResult["mwloss"];?></td>
</tr>
<?
$a++;
    }
    ?>
    </table>
    <table width="100%" height="52" border="1">
      <tr>
        <td width="123"><? echo "ชั่วโมงสะสม" ?></td>
        <td width="967">
        <?php
    $arr = array("$hour");
    echo  timeplus($arr);
?>
</td>
      </tr>
      <tr>
        <td><? echo "MW สะสม" ?></td>
        <td><?php $query = "SELECT * FROM outageevent ";
$query_run = mysql_query($query);
$sum1= 0;
while ($row_Recordset1['mwloss']= mysql_fetch_assoc ($query_run)) {

    $sum1+= $row_Recordset1['mwloss']['mwloss'];
}
echo $sum1; ?>    
</td>
      </tr>
    </table>
    <br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
    echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}

for($i=1; $i<=$Num_Pages; $i++){
    $Page1 = $Page-5;
    $Page2 = $Page+5;
    if($i != $Page && $i >= $Page1 && $i <= $Page2)
    {
        echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
    }
    elseif($i==$Page)
    {
        echo "<b> $i </b>";
    }
                                }
if($Page!=$Num_Pages)
{
    echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Num_Pages]'>... Next>></a> ";
}

    mysql_close();

?>
</body>
</html>
</html>
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่