Page 3 of 3 FirstFirst 123
Results 21 to 27 of 27
  1. #21
    Join Date
    Jun 2004
    Location
    USA
    Posts
    59
    I think I messed up the code really bad. It was working fine but forgot to make a back up of the script and went back to square one. Now I got everything to work as before with one exeption I had the code make 3 colums of pictures amd however many rows as it takes. Now It wont do it no matter where I try. Here is the code is working so far.



    $count = 0;
    $dir = "D:\Server\Structure\work\pictures";
    if (is_dir($dir))
    {
    if ($dh = opendir($dir))
    { while ($file = readdir($dh))
    { if ($file != '.' && $file != '..')
    {



    echo '<img src="'.$dir.'/'.$file.'"><br>'."\r\n";

    $file = str_replace(".jpg", "", $file);
    $file = str_replace(".gif", "", $file);

    echo "<CENTER>".$file . "<BR><BR></CENTER>";
    $count++;

    }
    }

    closedir($dh);
    }
    }

    echo 'total files = '.$count;

  2. #22
    Join Date
    Mar 2003
    Location
    Santa Rosa, CA
    Posts
    49
    Look back to page 2 and the 2nd reply of this thread. I show how to print out the images by using a for loop and modulus.

    // 3 being how many imgs to print before a new table row.
    if ($i % 3 == 1) echo "</tr><tr>";

    Also if you still want to print the images alphabetically don't forget to put them into an array first, sort, then print also like shown in the page 2, 2nd reply of this thread.
    - shamabaghodia!

  3. #23
    Join Date
    Jun 2004
    Location
    USA
    Posts
    59
    The long battle is finally over and let me be the first to say that it was a big headache but feels damn good after it's finished.

    First the credits!

    mikemmx
    First member to give imput to a gallery like script.
    helping along this tread.

    shamabaghodia
    Helping every step of the way and did just about 99.99% of the script. Helped in how to edit lines from a text using php script.

    drknow
    Helping on how to return to next line in MS text \r\n in doing so helped make the script/html clean and easy to read.

    Sion
    Gave us input on what is cross platform and how much of a headache this can give anyone. Plus a little hack. I am saving that for later when I am able to understand and put it in good use.

    Demondo
    Thanks for not banning me so I could learn all this and get a bigger headache as the script got bigger.

    3dbuzz.com
    For having this site with cool people that know their stuff!


    So here is the final script that did the stuff I wanted.



    echo "<TABLE> \r\n";


    $count = 0;
    $dir = "D:\Server\Structure\work\pictures";
    if (is_dir($dir))
    {
    if ($dh = opendir($dir))
    { while ($file = readdir($dh))
    { if ($file != '.' && $file != '..')
    {


    for ($i=0; $i<$count; $i++)
    {
    if ($i % 3 == 1)
    {
    $tr = "\r\n"."</TR><TR>";
    }else{
    $tr = "";
    }
    }

    @sort($file);

    echo '<TD><IMG SRC="'.$dir.'\\'.$file.'">';
    echo '<BR clear="all"><CENTER>';
    $file = str_replace(".jpg", "", $file);
    $file = str_replace(".gif", "", $file);
    echo $file.'</CENTER></TD>'.@$tr."\r\n";


    $count++;


    }
    }

    closedir($dh);
    }
    }

    echo "</TABLE> \r\n";
    echo 'total files = '.$count;



    I placed an @ on @sort($file); and @$tr because they gave a weird notice. I CAN live with that. I just made sure it didn't come up on the html. Well I am happy with the script.

    Thanks everyone!

    Until the next project. I won't be giving you guys a headache too.

    P.S. Should be about a few days or so. LOL

  4. #24
    Join Date
    Dec 2002
    Location
    United Kingdom
    Posts
    635
    Your welcome m8


    that's what the buzz comunity is here for
    Saiweb ~ Ramblings of a sysadmin

    My Current Recomended WebHost: Nativespace



    "Acies Latin: a sharp edge or point; mental acuity, sharpness of vision"

    NOTE: Acies is currently beta, the "down" page will be displayed untill I have finished a release candidate

    3DBuzz has a reputation system please rate posts using the icon

  5. #25
    Join Date
    Jun 2004
    Location
    USA
    Posts
    59
    I just couldn't sleep. I needed to figure out why the other script didn't work. Found a little bypass. That eased the code quite nicely if I say so. Plus it let me rest too.

    PHP Code:

    <?php
    $path 
    "pictures";
    $IMGS = array();

    $d dir($path);
    while (
    false !== ($entry $d->read())) {
        if (
    $entry != "..") if ($entry != ".")
        
    $IMGS[] = $entry;
    // while d->read
    $d->close();

     
    sort($IMGS); // Alpha Sort
    $count sizeof($IMGS); // Count IMGs

    if ($count 0) {
    ?>
    <table cellpadding="5" cellspacing="0" border="0"><tr>

    <?php
        
    for ($i 1; list($key$val) = each($IMGS); $i++) {
                if (
    $i == 1) echo "</tr><tr>";
    ?>
    <td>
    <a href="<?php echo $path."/".$val?>">
    <img src="<?php echo $path."/".$val?>"></a><br />
    <BR clear="all">
    <? $val = str_replace(".jpg", "", $val) ?>
    <? $val = str_replace(".gif", "", $val) ?>
    <CENTER> <? echo $val; ?> <CENTER>
    </td>

    <?php
    // for each IMGS
    ?>

    </tr></table>

    <?php
    // count > 0
    echo "Total picture count is: ".$count;
    ?>
    Last edited by Teske; 06-16-2004 at 07:24 AM.

  6. #26
    Join Date
    Dec 2002
    Location
    United Kingdom
    Posts
    635
    Hehehe

    Im exactly the same, if something is vexing me I have to finish it before I can relax.

    Even if is means creating a hack/workaround to patch it and force it to work
    Saiweb ~ Ramblings of a sysadmin

    My Current Recomended WebHost: Nativespace



    "Acies Latin: a sharp edge or point; mental acuity, sharpness of vision"

    NOTE: Acies is currently beta, the "down" page will be displayed untill I have finished a release candidate

    3DBuzz has a reputation system please rate posts using the icon

  7. #27
    Join Date
    Jun 2004
    Location
    USA
    Posts
    59
    :::ERRRRR.... Crash:::

    Ok I just hit a wall so hard that it almost hurt.
    PHP is doing a great job at the gallery but I just saw a problem.
    after 40 thumbnails it becomes a little too big to keep going with the gallery. I been looking around and found a couple of codes that can make it work but its a no go for me.

    How can I make the script break and make another page instead of going and non stop?

    This is the code that I found but dont know how to make it work or should I say its not working as it should.

    url/gallery.php?num=0

    $num = $_GET[num];
    $page = 15;

    if($page)
    {

    -- gallery code here but it doesn't work that way --

    $page--;
    }


    $pages=$num;
    $add=$pages+15;
    $sub=$pages-15;

    if ($count>$add+1)
    {
    print ("<a href=gallery.php?num=$add>next pages</href><br>");
    }

    if ($pages>14)
    {
    print ("<a href=gallery.php?num=$sub>previus pages</href><br>");
    }


    This is all cool and all but I cant get it to work.

Page 3 of 3 FirstFirst 123

Posting Permissions

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