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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use ajax and php as an intermediate :
Define an empty JS array :
var myarray = new Array();use ajax to call your php script, javascript will eval the output by PHP (note this uses prototype library):
Write your PHP code to grab data and print JS code (it must be valid javscript !) :
You can check that your Js array contains data :
hope this helps.