mysql - How to send multiple json response in php back to ajax -




<?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 * studentdetails inner join studentmarks on studentdetails.studentid=studentmarks.studentid firstname='$fname' , sem='$sem'");     $re = array();     while ($row = mysqli_fetch_assoc($query))     {         print_r($row);         //$options['userobj'][]=$row;     } }  echo json_encode ($re); return; ?> 

this full php code in need 2 json responses, 1> when refresh page

$sql="call regtask2('$userid')"; 

this query has work , pass response ajax, using click button. when use click button query has work , pass response

$query = mysqli_query($conn,"select * studentdetails inner join studentmarks on studentdetails.studentid=studentmarks.studentid firstname='$fname' , sem='$sem'"); 

i poosible?

3 options:

  1. just split php code. on refresh, load script1.php , other ajax call, load script2.php.
  2. you need set identifiers calls. in ajax, add "is_submit=true" query. in php, check value.
  3. assign return value $return , return that.




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -