PHP - MySQL results to JSON -
I am trying to convert a MySQL result to a JSON format so that I can later use this JSON Javascript to create an HTML table. Although my code produces very nil values and why I am still not understood.
$ result = mysqli_query ($ con, "select from clients"); $ test = json_encode ($ result); Print $ test; Output: {"current_field": null, "field_count": zero, "length": blank, "num_rows": empty, "type ": null} I have fields like, for example," customer ID "and" name ", and even they do not even appear in JSON results.
What am I doing wrong? Thanks
$ result = mysqli_query ($ con, "select from customers"); While ($ line = mysqli_fetch_assoc ($ result)) $ test [] = $ line; Print json_encode ($ test);
Comments
Post a Comment