|  | 
	                
  
    | 
	 
        ทำเมนู แบบ แปรผันกันจากฐานข้อมูลแล้วไม่เปลี่ยน ตรงรายการที่ 3 เพราะอะไร รบกวนดู code ให้หน่อย     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เหมือนจะมี <?=$result_sub[sub_name_th];?> ของ Select อันที่ 3 ต้องเป็น <?=$result_sub[sub1_name_th];?> ป่าว แถมแบบ ajax ไม่ได้เทสนะคับ มั่วๆเอา
 product.php
 
 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <table>
        <tr>
            <td>
                <select name="catalog" id="catalog">
                    <?php
                    include ("connect.php");
                    $cat_id=$_GET['cat_id'];
                    $sql="select * from tb_product1 order by cat_id ASC";
                    $dbquery=mysql_db_query($dbname,$sql);
                    while($result=mysql_fetch_array($dbquery)){
                            echo '<option value="'.$result[cat_id].'">'.$result[cat_name_th].'</option>';
                    }
                    ?>
                </select>
            </td>
        </tr>
        <tr>
            <td>
                <select name="subcatalog" id="subcatalog"></select>
            </td>
        </tr>
        <tr>
            <td>
                <select name="subcatalog1" id="subcatalog1"></select>
            </td>
        </tr>
    </table>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $('#catalog,#subcatalog').change(function(){
                var type = $(this).attr('id');
                var find_id = $(this).val();
                $.ajax({
                    url: 'catalogJson.php',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        target: type,
                        toFind: find_id
                    }
                })
                .done(function(response){
                    if(type == 'catalog'){
                        $('#subcatalog').empty();
                        $.each(response, function(key, val){
                            $('#subcatalog').append('<option value="'+ val.sub_id +'">'+ val.sub_name_th +'<option>');
                        });
                    }else{
                        $('#subcatalog1').empty();
                        $.each(response, function(key, val){
                            $('#subcatalog1').append('<option value="'+ val.sub1_id +'">'+ val.sub1_name_th +'<option>');
                        });
                    }
                });
            });
        })
    </script>
</body>
</html>
 catalogJson.php
 
 <?php 
    header('Content-Type:application/json');
    include ("connect.php");
    $type = $_POST['target'];
    $find_id = $_POST['toFind'];
    $response = array();
    if($type == 'catalog'){
        $sql_sub="select * from tb_subproduct where cat_id = '$find_id' ";
        $dbquery=mysql_db_query($dbname,$sql);
        while($result=mysql_fetch_array($dbquery)){
            array_push($response,array('sub_id'=>$result['sub_id'],'sub_name_th'=>$result['sub_name_th']));
        }
    }else{
        $sql_sub="select * from tb_subproduct_1 where sub_id = '$find_id' ";
        $dbquery=mysql_db_query($dbname,$sql);
        while($result=mysql_fetch_array($dbquery)){
            array_push($response,array('sub1_id'=>$result['sub1_id'],'sub1_name_th'=>$result['sub1_name_th']));
        }
    }
    
    echo json_encode($response, TRUE);
?>
 |  
              | 
 ประวัติการแก้ไข
 2015-06-23 00:34:05
 2015-06-23 00:35:08
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2015-06-23 00:28:25 | By :
                            Krungsri |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 |  |