Results 1 to 4 of 4

Thread: Please help me with PHP arrays and javascript

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2010
    Posts
    33

    Please help me with PHP arrays and javascript

    I have had alot of trouble finding a good explanation on this. I went up and down on the web most of today.

    If someone can help with this, please include complete code in the post.

    Here it goes.

    I would like to read the contents of a directory into an array using PHP (The filenames of images). After this, I would like to be able to show the images one by one by clicking on a next and a a previous link. The only way to do this, I found out is using Javascript. How can I do this. Please post example code of how to do this, if you know how. I already know that you have to use Javascript with PHP.

    This is what I have so far. It displays only a single image from the images/ directory, because there is no Javascript interaction. Can someone extend this to use with Javascript. However, the entire directory is read into the $filename array. So, accessing specific images is easy server side, but not client side. The only thing I can do with this is create an image rotator.
    <html>

    <head>
    <title>test</title>

    </head>

    <body>

    <?php

    $filename = glob("images/*.bmp");

    echo "<img src=\"$filename[0]\" />";

    ?>

    </body>


    </html>
    Last edited by securobo; Sep 4th, 2010 at 11:43 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width