0
<?php
session_start();
$conn =new mysqli("localhost","root","","registration");
$userid=isset($_POST['userid'])?$_POST['userid']:'';
//$re['success']=false;
$sql="call regtask2('$userid')";
$res=mysqli_query($conn,$sql);
$array = array();
if($res) {
while($row = mysqli_fetch_assoc($res))
{
$array[]=$row ;
$re['success']=true;
$re['userObj']['firstname'] = $row['firstname'];
}
}
else {
$re['success']=false;
}
if(isset($_SESSION['username']))
{
$sem=isset($_POST['sem'])?$_POST['sem']:'';
$fname=isset($_POST['fname'])?$_POST['fname']:'';
$year=isset($_POST['date'])?$_POST['date']:'';
$query = mysqli_query($conn,"select * from studentdetails inner join studentmarks on studentdetails.studentid=studentmarks.studentid where firstname='$fname' and sem='$sem'");
$re = array();
while ($row = mysqli_fetch_assoc($query))
{
print_r($row);
//$options['userObj'][]=$row;
}
}
echo json_encode ($re);
return;
?>
這是本我的完整的PHP代碼,我需要兩個JSON響應, 1>當我刷新頁面如何發送的PHP多JSON響應回到阿賈克斯
$sql="call regtask2('$userid')";
這個查詢有工作並將響應傳遞給ajax,然後我使用單擊按鈕。當我使用單擊按鈕,此查詢有工作並通過響應
$query = mysqli_query($conn,"select * from studentdetails inner join studentmarks on studentdetails.studentid=studentmarks.studentid where firstname='$fname' and sem='$sem'");
我這是poosible?
目前還不清楚你期望的結果。你能提供一個你期望的查詢結果的例子嗎? 此外,你是什麼意思_multiple json response_? –
我使用兩個使用相同的PHP Ajax,我期待兩個不同的答覆不同 – Maha