How can I create two related tables in MySQL and return a result set as JSON using PHP? [closed]
I need to create two related tables in MySQL and return a result set as JSON using PHP.
I have figured out how to get my data from MySQL using PHP and how to encode it to JSON, but I'm not sure how to use Javascript to display the JSON results on my page.
Any help would be appreciated.
This is a very vague question, but here are all the pieces you'll need. Put them together in the way which solves your particular problem:
Basic MySQL usage example: http://us3.php.net/manual/en/mysql.examples-basic.php
Full MySQL documentation: http://us3.php.net/manual/en/book.mysql.php
Getting data from related tables: http://www.keithjbrown.co.uk/vworks/mysql/mysql_p5.php (JOIN directive)
Encode your data in JSON: http://php.net/manual/en/function.json-encode.php
精彩评论