php - Display ajax called data in a table -


I have this Ajax call which is a Jason array with PHP file I have to put the data into rows in a table that is in #gamesList

I have an attachment, I do not know how to go through the returned Jason array and insert it in the attachment

  $ ("# ALL"). Work () {$. AJAX ({url: 'getGames.php', type: "post", data type: 'jason', data: ({btn: 'ALL'}), success: work (data) {// returning through game Games displayed in Loop // Table $ ("#Glistslist") via GO // game ('& lt; tr & gt; & lt; td & gt; name & lt; / td & gt; & lt; ; TD & gt; M & lt; / td> & lt; Td & gt; (2) Entries & lt; / td & gt; & lt; td & gt; (5) Maximum people & lt; / td & gt; & lt; td & gt; ($ 100) & lt; / td> & lt; td & gt; Awards & lt; / td & lt; td & gt; 7:00 PM (Start)  & lt; / tr & gt; ';)}}})}}; // btn click   

the PHP file returns those lines

  $ res = mysqli_query ($ c, "SELECT * FROM games"); While ($ row = mysqli_fetch_array ($ res)) {$ games [] = $ line; } Echo json_encode ($ games)    

Do not just result with html and JSON Please. See the edits and comments below

  $ ("# ALL"). Click (function () {$ .ajax ({url: 'getGames.php', type: "POST", // json from html data: 'html', data: ({BTN: 'ALL'} ), Success: function (data) {// display game table div is resized from PHP file inside $ ("#Glistslist") .html (data);}}); // normal form submission return false stop;} ); // BTN click   

You make a minor change to the PHP file and run it through a loop

  $ res = mysqli_query ($ C, "SELECT * game"); While ($ line = mysqli_fetch_array ($ res)) {// $ games [] = $ line; ?} & Gt; & Lt; Table & gt; & Lt ;? Php foreach ($ res as $ game) {? & Gt; & Lt; TR & gt; & Lt; TD & gt; & Lt ;? Php echo $ game ['TABLE_COLUMN_NAME'] ;? & Gt; & Lt; TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; / Table & gt;   

Each $ game has a line in your DB table. This code resonates a table with all the rows and dumps the contents of this fee file into the list of games.

Hope it helps!

- Nick

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -