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,