在javascript数组中显示mysql结果

This is an javascript array where you put images and their are displayed:

    orakuploader_attach_images: ['cat.jpg', 'dolphin.jpg', 'lion.jpg'],

Now i have a database where I want to grab the images from database and want to add them to this array somehow. So how can I fetch the names from the database and put them in this array so they are displayed properly?

Any ideas?

Use .push():

orakuploader_attach_images.push("fourth.jpg");

Or you can include a php file by:

var orakupload_attach_images = <?php include(array_image.php); ?>

The file array_image.php will have the array of images from your database:

echo json_encode(array('cat.jpg', 'dolphin.jpg', 'lion.jpg'));

Or call them by Ajax:

$.get( "array_image.php", function( data ) {
    var orakupload_attach_images = data;
    /* DO THE REST OF YOUR ACTION HERE */
});

This was my solution:

    orakuploader_attach_images: [
    <?php while($e=$get_photos_query->fetch(PDO::FETCH_BOTH)) 
    {
          echo "'".$e['photo_name']."',";

    }
    ?>],
var len = <?php echo count($phpArr); ?>
var jsArr= <?php echo json_encode($phpArr); ?>;    

for(var i=0; i<len; i++){
    console.log(jsArr[i]);
}