Jump to content

johngary

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

johngary's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry for that just new to forums.....can you do any changes with sorting codes on my script? thanks.
  2. I'm bit new to php and I got this code on my site but however Id like this to change the images to show up in the right order of sequence. My images are number from 1.jpg, 2.jpg and so on but on my site it appears to be in random... Anyone please can fixed this... <?php $p = $_GET['p']; if ($handle = opendir("images/rootfolder/")) { $i = 1; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $img[$i] = $file; if ($p == $img[$i]) { $ci = $i; } $i++; } } closedir($handle); $ti = $i - 1; $pi = $ci - 1; if ($p == "") { $ni = $ci + 2; } else { $ni = $ci + 1; } $prevNext = ""; if ($pi > 0) { $piFile = $img[$pi]; $prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $piFile . "\" title=\"show previous image\">Previous</a>"; } else { $prevNext .= "Previous"; } $prevNext .= " | "; if ($ni <= $ti) { $niFile = $img[$ni]; $prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $niFile . "\" title=\"show next image\">Next</a>"; } else { $prevNext .= "Next"; } if ($p == "") { $p = $img[1]; } } ?>
  3. I have place a php file for image viewer and everything works fine. But my problem here is that when I open it the pictures were showing in random order not in proper sequence of number. Can anyone help me with this php file to make the pictures shows up in the right sequence of number. like 1.jpg-2.jpg....... Thank you very much and your help will be much appreciated. The pictures on my server arrange like this: 1.jpg 11.jpg 12.jpg 2.jpg 22.jpg 4.jpg and so on.... All the photos are numbered also in order. When I open the page it shows the name of the page not the number of the image it looks like this: www.mysite.com/file.php (with a picture) then when I click the next button that shows up like: www.mysite.com/file.php?p=18.jpg then next image shows like: www.mysite.com/file.php?p=6.jpg and so on like in random order. Can you correct it to make it in right order like: p=1, p=2, p=3 and so on... This is the code I placed. $p = $_GET['p']; if ($handle = opendir("images/myfolder/")) { $i = 1; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $img[$i] = $file; if ($p == $img[$i]) { $ci = $i; } $i++; } } closedir($handle); $ti = $i - 1; $pi = $ci - 1; if ($p == "") { $ni = $ci + 2; } else { $ni = $ci + 1; } $prevNext = ""; if ($pi > 0) { $piFile = $img[$pi]; $prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $piFile . "\" title=\"show previous image\">Previous</a>"; } else { $prevNext .= "Previous"; } $prevNext .= " | "; if ($ni <= $ti) { $niFile = $img[$ni]; $prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $niFile . "\" title=\"show next image\">Next</a>"; } else { $prevNext .= "Next"; } if ($p == "") { $p = $img[1]; } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.