<?php
include 'connection.php';
$array = array();  
$query = "SELECT * FROM topic";  
$result = mysqli_query($mysqli , $query);  
while($row = mysqli_fetch_assoc($result))  
{  
    $array[] = $row;  
    }  
    echo json_encode($array)

?>