I am studying android. And I have database in MySQL
, I want to transfer some data from database to android to show it like ListView. I have learned that I need PHP , and JSONArray
. And that is my colums in MySQL
:
My code in PHP :
$query = mysqli_query($con,
"SELECT * FROM market ORDER BY id ");
$someArray = [];
while ($row = mysqli_fetch_assoc($query)) {
array_push($someArray, [
'id' => $row['id'],
'nick' => $row['nick'],
'percent' => $row['percent'],
'minimum' =>$row['minimum'],
'logo_small' => $row['logo_small'],
'logo_big' => $row['logo_big'],
'name' =>$row['name'],
'phone' => $row['phone'],
'position'=> $row['position']
]);
}
echo json_encode($someArray);
AND It works!
what i get :
BUT when I want to add (or write it instead of getting name or nick or etc.)
'adresses' => $row['adresses']
complete code when add this:
<?php
$con = mysqli_connect(".....", ".....", ".....", "......."); //private
$query = mysqli_query($con,
"SELECT * FROM market ORDER BY id ");
$someArray = [];
while ($row = mysqli_fetch_assoc($query)) {
array_push($someArray, [
'id' => $row['id'],
'nick' => $row['nick'],
'percent' => $row['percent'],
'minimum' =>$row['minimum'],
'logo_small' => $row['logo_small'],
'logo_big' => $row['logo_big'],
'name' =>$row['name'],
'phone' => $row['phone'],
'position'=> $row['position'],
'adresses'=>$row['adresses']
]);
}
echo json_encode($someArray);
?>
or
'description'=> $row['description']
It is not working...
when i add these lines(or one of them) i get this (empty):
Data in db for adresses and description(i have only 4 titles)
I can't get adresses and description. What is a problem?
maybe in database?
Reason: Because of the special symbols(é, ü, ç) in db there was an error.