2015-09-28 142 views
-3

這裏之後,從數據庫的組合框的值是我的html代碼:我想滿足某種條件

<form action="ProductProcess.php" method="post"> 
    <h1> Update</h1> 
     <label>Product Type: </label> 
     <select name="protype"> 
      <option> Hair Treatment </option> 
      <option> Hair Styling</option> 
     </select> <br> <br> 

     <label>Product Name</label> 
     <select name="proname"> 
      <option> 
      //Here i want the values 
      </option> 
     </select><br> <br> 
     </form> 

這裏是工作的PHP代碼:

<?php 
    $protype=$_POST['protype']; 
    //Connect 
    $query=mysql_query("Select Product_Name from tbl_Products where Product_Type='".$protype."'");    
      if(!$numrows=mysql_num_rows($query)==0) 
      { 
       while($row=mysql_fetch_assoc($query)) 
       { 
        echo $row['Product_Name']; 
       } 
      } 
?> 

PHP代碼顯示值在另一頁上。我想要在上面的HTML頁面的組合框上的結果。

+1

[我如何問一個**好**問題?](http://stackoverflow.com/help/how-to-ask) –

回答

0

您只需將工作代碼放置在<select>標記內。

<select name="proname"> 
    <option> 
    <?php 
     $protype=$_POST['protype']; 
     //Connect 
     $query=mysql_query("Select Product_Name from tbl_Products where Product_Type='".$protype."'");    
     if(!$numrows=mysql_num_rows($query)==0) 
     { 
      while($row=mysql_fetch_assoc($query)) 
      { ?> 
       <option value="<? echo $row['Product_Name']; ?>"> 
       <? echo $row['Product_Name']; ?> 
       </option> 
      <? } 
     } 
     ?> 
</select> 
+0

非常感謝你兄弟 –