I am sending a sql query to fetch a data from database but the output is showing the column name as it's value. Following are the codes and output respectively:
<?php
include_once("connect_db.php");
$query1 = "SELECT 'first_name' FROM user_details WHERE email='saptakds@gmail.com'";
$result1 = mysqli_query($conn,$query1);
$myArray = array();
while($row = $result1->fetch_array(MYSQLI_ASSOC)) {
$myArray[] = $row;
}
echo '{"maal":';
echo json_encode($myArray, JSON_UNESCAPED_SLASHES);
echo ',"message" : "success"}';
?>
Output:
{"maal":[{"first_name":"first_name"}],"message" : "success"}
The desired output should have been the following:
{"maal":[{"first_name":"Saptak"}],"message" : "success"}