JSON is syntax for storing and exchanging text information. Much like XML. JSON is smaller than XML, and faster and easier to parse. I have decided to try to use PHP to return data in JSON format to Jquery Ajax . After doing some research , i found two tutorials which i am going to try when i am free.
I would update you this post again when i have tried it out
Finally after what seems like months , i have returned to this question
I was thinking of how to convert a string to a JSON object in PHP , it is done by using the json_decode method . Please refer here .
To convert array to JSON object , it is done by the json_encode method . Please refer here
I then thought how to iterate over the json object once i got it , Please refer here
Now i have a problem , everytime i stmt->fetch , how do i store it inside it in an associative array .
Qn : everytime i stmt->fetch , how do i store it inside it in an associative array .
Ans: retrning an associative array from mysqli statement result
I would have to use json_encode to convert the associative array into an JSON object
Once an JSON object was returned i knew i had to iterate over each item in the JSON object using .each as shown by my previous day research but the SO ans didnt really show how to iterate over a associative array so i went to google for an example and found jquery loop on Json data using $.each which really taught me everything i needed to know
The last part was just .append the html and .empty() the table body everytime a user selects a new category. During the .append portion , i made a really stupid mistake with my string concatenation where i forgot to the + sign and had syntax error . I even asked the qn on SO and deserving got downvoted :(
I have a new problem now , if there are too many words for the column , the data wouldnt render at all and give a null instead . I wonder why????