suppose i have an javascript array "userName".I want to load it from a database table named "user".
Can anyone help with idea or sample code?
Thanks
suppose i have an javascript array "userName".I want to load it from a database table named "user". Can anyone help with idea or sample code? Thanks |
|||||||||||||
|
Use ajax and php as an intermediate :
hope this helps. |
||||
|
This creates a global
If you're looking for a dynamic AJAXy solution, follow some tutorials about AJAX. |
|||||||||
|
You'll have to use the To fill your array with the user names, you'd do something like this.
|
|||
|
The best way to do that simply is to get your data in your php code, and then "write" the javascript code to generate the array in php. A short example would be :
My code could be quite incorrect, it's juste to give you a quick example. You could also do that in a more elegant way, using json. |
|||||||||
|