weixin_33726943 2018-09-17 16:14 采纳率: 0%
浏览 19

PHP多个下拉选择

Hoping someone can help me with this... I have a program I am writing in PHP and ajax that has multiple select boxes and with each select populates the next drop down box. I need to $_Post multiple options and use these to run a mysql query. Here is my layout:

I have:

<div class="row">
<label>Camera:</label><br/>
<select name="camera" id="camera-list" class="demoInputBox" 
onChange="getCod(this.value);">
<option value="">Select Camera</option>
</select>
</div>
<div class="row">
<label>Codec:</label><br/>
<select name="codec" id="codec-list" class="demoInputBox" 
onChange="getFra(this.value);">
<option value="">Select Codec</option>
</select>
</div>
<div class="row">
<label>Framerate:</label><br/>
<select name="framerate" id="framerate-list" class="demoInputBox">
<option value="">Select Framerate</option>
</select>
</div>

with function:

function getCod(val) {
$.ajax({
type: "POST",
url: "get_codec.php",
data:'camID='+val,
success: function(data){
    $("#codec-list").html(data);
}
});
}

function getFra(val) {
$.ajax({
type: "POST",
url: "get_framerate.php",
data:'codID='+val,
success: function(data){
    $("#framerate-list").html(data);
}
});
}

how do I retrieve both Post values to use in a mysql query

example mysql query i am trying to run:

<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_POST["camID"]["codID"])) {
$query ="SELECT framerate FROM cam_stat WHERE (cam_id = '" . $_POST["camID"] 
. "') and ( codec = '" . $_POST["codID"] . "')";
$results = $db_handle->runQuery($query);
?>
<option value="">Select Framerate</option>
<?php
foreach($results as $framerate) {
?>
<option value="<?php echo $framerate["ID"]; ?>"><?php echo 
$framerate["framerate"]; ?></option>
<?php
}
}
?>

mysql table sample:

ID, cam_id, resolution, codec, framerate, compression, datarate

Note: in this table there can be multiple codecs that are the same for each cam_id, I am trying to get the next select box to show the possible framerates where the cam_id equals the selected and the codec also equals the selected.

I am new to posting on these kind of threads so forgive me if my question doesnt make since... i am trying to retrieve the post of camid and codid to insert into my query... any help would be much appreciated. Thanks,

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置