Answer the question
In order to leave comments, you need to log in
How to get SQL query in JSON?
Good evening.
How can I get a SQL response in JSON like this?
SELECT `cat_id`,`title` FROM `product`;
Answer the question
In order to leave comments, you need to log in
$sql = 'SELECT `cat_id`,`title` FROM `product`;';
$res = $mysqli->query($sql);
$rows = $res->fetch_all(MYSQLI_ASSOC); //ответ из базы
echo json_encode($rows); // json
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question