www.webdeveloper.com
Results 1 to 4 of 4

Thread: PHP Code in javascript?

  1. #1
    Join Date
    Dec 2006
    Posts
    115

    PHP Code in javascript?

    hi all

    I have the following code in teh javascript function
    i wanna get these values from MySQL though PHP. how can I or I cant?


    Code:
    		["slideshow/1.jpg", "slide_files/links/1.php", "_new", ""],
    		["slideshow/2.jpg", "slide_files/links/2.php", "", ""],
    		["slideshow/3.jpg", "slide_files/links/3.php", "", ""],
    		["slideshow/4.jpg", "slide_files/links/4.php", "", ""],
    		["slideshow/5.jpg", "slide_files/links/5.php", "", ""],
    		["slideshow/6.jpg", "slide_files/links/6.php", "", ""]
    thanks in advance

    regards
    Jack

  2. #2
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    You may need to explain yourself a lot clearer. What are you after getting from MySQL? What have you tried? How does the table look? Do you already have code for a connection?...

  3. #3
    Join Date
    Apr 2008
    Posts
    157
    Just do something like this:

    PHP Code:
    while ($result $db->fetchArray()) {
        echo 
    '["slideshow/'.$result["id"].'", "slide_files/links/'.$result["id"].'", "'.$result["target"].'", ""],'."\n";

    Where `id` is 1,2,3,4,5,6 and `target` is "_new" or "" (_new should be "_blank" btw)

  4. #4
    Join Date
    Dec 2006
    Posts
    115
    Quote Originally Posted by scragar View Post
    You may need to explain yourself a lot clearer. What are you after getting from MySQL? What have you tried? How does the table look? Do you already have code for a connection?...

    below is my complete code of javascript for a slide showeshow...

    actually I am uploading the images in MySQL database. the below code creates a slideshow with images from database... this codes uses 6 images... which is static kind of slideshow. i want something where the user enter as many images as he wants and it will loop through the record set from the database... so the imagearray in the javascript i need from the database....


    Code:
    <script type="text/javascript">
    
    var mygallery=new simpleGallery({
    	wrapperid: "simplegallery1", //ID of main gallery container,
    	dimensions: [427, 323], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
    	imagearray: [
    		["slideshow/1.jpg", "slide_files/links/1.php", "_new", ""],
    		["slideshow/2.jpg", "slide_files/links/2.php", "", ""],
    		["slideshow/3.jpg", "slide_files/links/3.php", "", ""],
    		["slideshow/4.jpg", "slide_files/links/4.php", "", ""],
    		["slideshow/5.jpg", "slide_files/links/5.php", "", ""],
    		["slideshow/6.jpg", "slide_files/links/6.php", "", ""]
    	],
    	autoplay: [true, 2500, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
    	persist: false, //remember last viewed slide and recall within same session?
    	fadeduration: 700, //transition duration (milliseconds)
    	oninit:function(){ //event that fires when gallery has initialized/ ready to run
    		//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
    	},
    	onslide:function(curslide, i){ //event that fires after each slide is shown
    		//Keyword "this": references current gallery instance
    		//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
    		//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
    	}
    })
    
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles