提交后,从选定的字段中回复“确定”

时间:2013-01-11 10:14:44

标签: php mysql submit echo

我有一个数据库“车辆”,表格“id”“年”“制造”“模型”“精确”。

我有4个下拉菜单,当你按提交时,你会得到所选的值:

它几乎正常工作,但我的上一个功能出现了问题...当显示最后一个下拉列表时,我可以选择与年份相匹配的所有准确...

例如,当我从2013年开始拥有50辆汽车时,它将显示与我选择的年份匹配的精确数据。

如何更改最后一项仅显示与“make”,“model”和“year”匹配的精确度的函数?

这是我的剧本,直到现在:

<?php
//**************************************
//     Page load dropdown results     //
//**************************************
function getTierOne()
{
    $result = mysql_query("SELECT DISTINCT make FROM vehicles ORDER BY make ASC") 
    or die(mysql_error());

      while($tier = mysql_fetch_array( $result )) 

        {
           echo '<option value="'.$tier['make'].'">'.$tier['make'].'</option>';
        }

}

//**************************************
//     First selection results     //
//**************************************
if (isset($_GET['func'])&& $_GET['func'] == "drop_1" ) {
drop_1($_GET['drop_var']);
}

function drop_1($drop_var)
{  
    include_once('db.php');
    $result = mysql_query("SELECT DISTINCT model FROM vehicles WHERE make='$drop_var' ORDER BY model") 
    or die(mysql_error());

    echo '<select name="drop_2" id="drop_2">
          <option value=" " disabled="disabled" selected="selected">Selecteer Model</option>';

           while($drop_2 = mysql_fetch_array( $result )) 
            {
              echo '<option value="'.$drop_2['model'].'">'.$drop_2['model'].'</option>';
            }

    echo '</select>';
    echo "<script type=\"text/javascript\">
$('#wait_2').hide();
    $('#drop_2').change(function(){
      $('#wait_2').show();
      $('#result_2').hide();
      $.get(\"func.php\", {
        func: \"drop_2\",
        drop_var: $('#drop_2').val()
      }, function(response){
        $('#result_2').fadeOut();
        setTimeout(\"finishAjax_tier_three('result_2', '\"+escape(response)+\"')\", 400);
      });
        return false;
    });
</script>";
}

//**************************************
//     Second selection results     //
//**************************************
if (isset($_GET['func'])&& $_GET['func'] == "drop_2" ) {
drop_2($_GET['drop_var']);
}

function drop_2($drop_var2)
{  
    include_once('db.php');
    $result = mysql_query("SELECT DISTINCT year FROM vehicles WHERE model='$drop_var2'") 
    or die(mysql_error());

    echo '<select name="drop_3" id="drop_3">
          <option value=" " disabled="disabled" selected="selected">Selecteer Jaar</option>';

           while($drop_3 = mysql_fetch_array( $result )) 
            {
              echo '<option value="'.$drop_3['year'].'">'.$drop_3['year'].'</option>';
            }

    echo '</select>';
    echo "<script type=\"text/javascript\">
$('#wait_3').hide();
    $('#drop_3').change(function(){
      $('#wait_3').show();
      $('#result_3').hide();
      $.get(\"func.php\", {
        func: \"drop_3\",
        drop_var: $('#drop_3').val()
      }, function(response){
        $('#result_3').fadeOut();
        setTimeout(\"finishAjax_tier_four('result_3', '\"+escape(response)+\"')\", 400);
      });
        return false;
    });
</script>";
}

//**************************************
//     Second selection results     //
//**************************************
if (isset($_GET['func'])&& $_GET['func'] == "drop_3" ) {
drop_3($_GET['drop_var']);
}

function drop_3($drop_var3)
{  
    include_once('db.php');

        $result = mysql_query("SELECT * FROM vehicles WHERE year='$drop_var3'") 
    or die(mysql_error());

    echo '<select name="drop_4" id="drop_4">
          <option value="" disabled="disabled" selected="selected">Selecteer Accu</option>';


           while($drop_4 = mysql_fetch_array( $result )) 
                {
                if ($drop_4['accu'] != "") {
              echo '<option value="'.$drop_4['accu'].'">'.$drop_4['accu'].'</option>';
                }
  }
    echo '</select> ';
    echo '<input type="submit" name="submit" value="Submit" />';
}

?>

0 个答案:

没有答案