Jump to content
MakeWebGames

Recommended Posts

Posted (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 by Script47
Posted

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.

Posted
"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. :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...