A code guide to generate JSON from mysql db in php