Script47 Posted January 13, 2014 Share Posted January 13, 2014 (edited) Title is pretty clear, is it possible? If so any tutorials or examples which show it? Edit Getting PHP table values and storing it in a JS array. Edited January 13, 2014 by Script47 Quote Link to comment Share on other sites More sharing options...
Guest Posted January 13, 2014 Share Posted January 13, 2014 Title isn't exactly clear, what are you doing with it? Where is the info coming from? Do you mean the actual markup of the table or the content? You may want to look at http://datatables.net/ for a jquery solution. Quote Link to comment Share on other sites More sharing options...
Script47 Posted January 13, 2014 Author Share Posted January 13, 2014 Updated OP to make it more clear. Quote Link to comment Share on other sites More sharing options...
Dave Posted January 13, 2014 Share Posted January 13, 2014 Updated OP to make it more clear. "PHP table values"... are you referring to a database table? I'm still confused what you're asking. It seems more like you're wanting to load a PHP array into Javascript. If so you'll probably want to look into JSON: http://www.caveofprogramming.com/frontpage/articles/php/php-json-an-example-javascript-json-client-with-php-server/ Quote Link to comment Share on other sites More sharing options...
Dayo Posted January 13, 2014 Share Posted January 13, 2014 file.php $query = $db->prepare("some query"); $query->execute(); echo json_encode($query->fetchAll(PDO::FETCH_ASSOC)); someJsFile.js $.post('file.php', function (data) { var jsArray = $.parseJSON(data); // Any data returned in file.php in a JS array }); Links: http://en.wikipedia.org/wiki/JSON http://www.json.org/ Quote Link to comment Share on other sites More sharing options...
Script47 Posted January 13, 2014 Author Share Posted January 13, 2014 "PHP table values"... are you referring to a database table? I'm still confused what you're asking. It seems more like you're wanting to load a PHP array into Javascript. If so you'll probably want to look into JSON: http://www.caveofprogramming.com/frontpage/articles/php/php-json-an-example-javascript-json-client-with-php-server/ Sorry pal, I thought I made it clear. :) file.php $query = $db->prepare("some query"); $query->execute(); echo json_encode($query->fetchAll(PDO::FETCH_ASSOC)); someJsFile.js $.post('file.php', function (data) { var jsArray = $.parseJSON(data); // Any data returned in file.php in a JS array }); Links: http://en.wikipedia.org/wiki/JSON http://www.json.org/ Thanks Dayo, this is what I mean't. :) Quote Link to comment Share on other sites More sharing options...
sniko Posted January 14, 2014 Share Posted January 14, 2014 "PHP table values"... are you referring to a database table? I'm still confused what you're asking. It seems more like you're wanting to load a PHP array into Javascript. If so you'll probably want to look into JSON: http://www.caveofprogramming.com/frontpage/articles/php/php-json-an-example-javascript-json-client-with-php-server/ plusoneforjson Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.