我正在尝试在函数内部设置会话,但我只是无法使其工作。我已经将会话开始移动到函数内部,但没有运气。
任何人都可以帮我解释为什么不设置$ _SESSION [' ajax_test_confirmed']?
session_start();
function ajax_appointment_stage_one($clinic_id,$data,$tomorrow,$conn){
$get_today_appointments = "SELECT appointment_id FROM appointments WHERE appointment_date LIKE '%$tomorrow%' AND clinic_id='$clinic_id' AND appointment_confirmed!='3' AND appointment_confirmed!='2'";
$result = $conn->query($get_today_appointments) or die($conn->error.__LINE__);
$num_appointments_total = $result->num_rows;
if ($num_appointments_total==0){
$return_value="N/A";
} else {
$get_today_appointments_confirmed = "SELECT appointment_confirmed FROM appointments WHERE appointment_date LIKE '%$tomorrow%' AND clinic_id='$clinic_id' AND appointment_confirmed='1'";
$result = $conn->query($get_today_appointments_confirmed) or die($conn->error.__LINE__);
$num_appointments_confirmed = $result->num_rows;
$return_value=(($num_appointments_confirmed/$num_appointments_total)*100);
$_SESSION['ajax_test_confirmed']=$return_value;
}
$arr=array("#".$data,$return_value);
$return_data=json_encode($arr);
echo $return_data;
}
$data=$_POST['div'];
$clinic_id=$_POST['clinic_id'];
$tomorrow=$_POST['tomorrow'];
include '../../includes/db_connect.php';
$data($clinic_id,$data,$tomorrow,$conn)