Echo within javascript function

For a website I am working on I use the jQuery Supersized full sreen slideshow. In the Supersized function the images are hard coded:

<script type="text/javascript">
      slide_interval    :   3000,		
      transition        :      1, 	
      transition_speed:	  1000,	
      slides:   [			
                           {image : 'page_backgrounds/home1.jpg'},
			   {image : 'page_backgrounds/home2.jpg'},  
                           {image : 'page_backgrounds/home3.jpg'},
                           {image : 'page_backgrounds/home4.jpg'},
			   {image : 'page_backgrounds/home5.jpg'},

But I actually would like to echo them within the function since the images I am going to use will come from the database:

$query = "
              BY	      sort_order";

How can I use PHP within the above function?

Thank you in advance!

You can use AJAX to get them or if the javascript is within the php script you can just loop through each image and echo it out like you would any other variable.

I have edited your code to give an example of what was meant about writing the images into the JQuery array.

while $res=…depends on method being used

Hi thank you for the response. I am not completely sure what you mean with the above?.