我試圖讓第一個函數中使用的變量$drop_var1
轉換爲第二個函數,我需要在查詢中使用SQL。每次我試圖通過爲全局變量或返回黑色或沒有數據的任何其他方法......我真的在失去了如何使這項工作變量和函數
//**************************************
// First selection results //
//**************************************
if($_GET['func'] == "drop_1" && isset($_GET['func'])) {
$return_value = drop_1($_GET['drop_var']);
}
function drop_1($drop_var1)
{
$TD_DB_RESOURCE = open_teradata_resource();
$result2 = "SELECT DISTINCT a.call_id as id, b.call_name as name FROM call_log as a, call as b WHERE cust_id in ($drop_var1) and src_row_cre_dt between '2015-12-26' and '2015-12-26' and a.call_id = b.call_id";
echo $result2."<br>";
$arr_results = odbc_exec($TD_DB_RESOURCE, $result2);
echo '<select name="drop_2" id="drop_2">
<option value=" " disabled="disabled" selected="selected">Choose API</option>';
while ($drop_2 = odbc_fetch_array($arr_results))
{
echo '<option value="'.$drop_2['id'].'">'.$drop_2['name'].'</option>';
}
echo '</select><br><br>';
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($_GET['func'] == "drop_2" && isset($_GET['func'])) {
$return_value = drop_2($_GET['drop_var']);
}
function drop_2($drop_var2)
{
$TD_DB_RESOURCE = open_teradata_resource();
$result3 = "SELECT DISTINCT rc FROM call_log WHERE call_id in ('$drop_var2') and src_row_cre_dt between '2015-12-26' and '2015-12-26' and cust_id in ($drop_var1)";
echo $result3."<br>";
$arr_results = odbc_exec($TD_DB_RESOURCE, $result3);
echo '<select name="drop_3" id="drop_3">
<option value=" " disabled="disabled" selected="selected">Choose API Error Code</option>';
while ($drop_3 = odbc_fetch_array($arr_results))
{
echo '<option value="'.$drop_3['rc'].'">'.$drop_3['rc'].'</option>';
}
echo '</select><br><br>';
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>";
}
這裏是查詢的樣子
SELECT DISTINCT a.call_id as id, b.call_name as name FROM call_log as a, call as b WHERE cust_id in ('123456789') and src_row_cre_dt between '2015-12-26' and '2015-12-26' and a.call_id = b.call_id
SELECT DISTINCT rc FROM call_log WHERE call_id in ('29') and src_row_cre_dt between '2015-12-26' and '2015-12-26' and cust_id in()
因爲'm試圖從第一個函數drop_var1裏面第二個函數drop_2 –