php - Displaying many rows using JSON -


i retrieving data database using json.the problem when try retrieve entire rows nothing displayed.if display single row successful.how display multiple rows.am using while loop . code trying display multiple rows :

<?php   header('access-control-allow-origin: *');    $con=mysqli_connect("localhost","root","?l:@colo2016//?[$^*@!(><)my~~~server~~2000]1620","test") or die("error in server");    $sql="select * test";    $qry=mysqli_query($con,$sql) or die(mysqli_error($con));      while($row=mysqli_fetch_row($qry)){            $table_data[]= array("first name"=$row['fname'],"last name"=$row['lname']);                }  echo json_encode($table_data);  ?>

any guide please?

inside loop need use => assignment operator rather =

$table_data[]= array( "first name" => $row['fname'], "last name" => $row['lname'] );  <?php      header('access-control-allow-origin: *');      $con=mysqli_connect("localhost","root","?l:@colo2016//?[$^*@!(><)my~~~server~~2000]1620","test") or die("error in server");     $sql="select * test";     $qry=mysqli_query($con,$sql) or die(mysqli_error($con));     /*       using `fetch_assoc` return assiciative array       rather numerically indexed    */      while( $row=mysqli_fetch_assoc( $qry ) ){         $table_data[]=array( "first name"=>$row['fname'],"last name"=>$row['lname'] );     }      echo json_encode( $table_data ); ?> 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -