Jump to content

tiny

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tiny's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. lol. yeah. it's now solved. Cos I was googling about how to sort files and found about array_multisort(), so I got kind of confused. But I got it all working now. Thank yoU:)
  2. oh, now I understand. Thank you so much. It finally worked
  3. Hi! I just wanted to know if I can use array_multisort(); to order images in a directory like this: gallery1.jpg gallery2.jpg gallery3.jpg gallery10.jpg gallery15.jpg
  4. Hi, I am still having trouble sorting my gallery. I tried to use natsort(); and I have this code: $path = "/mypath"; $images=array(); $dh = @opendir($path) or die("Unable to open $path"); echo "Directory Listing of $path<br/>"; $i=0; while($f = readdir($dh)) { if(is_dir($f)) { continue; } else if($f != '.' && $f != '..') { //echo "<a href='$path/$file'>$file</a><br/>"; $images[$i]=$f; $i++; } } natsort($images); for($i=0; $i<sizeof($images); $i++) { echo "<a href=".chr(34).$path.$images[$i].chr(34).">".$images[$i]."</a><br/>"; } closedir($dh); the result still comes up this way.. gallery1.jpg gallery10.jpg gallery11.jpg gallery12.jpg gallery2.jpg gallery3.jpg gallery4.jpg gallery5.jpg gallery6.jpg gallery7.jpg gallery8.jpg gallery9.jpg what should i do? please help. thank you
  5. Thank you for your reply. I read about natsort and tried to put it on my code: What I changed on the last part of my code was this: $i = 0; while($fileList[$i] != ""){ $i++; } natsort($fileList); print_r($fileList); and the result was something like this: Array ( [0] => gallery1.jpg [4] => gallery2.jpg [5] => gallery3.jpg [6] => gallery4.jpg [7] => gallery5.jpg [8] => gallery6.jpg [9] => gallery7.jpg [10] => gallery8.jpg [11] => gallery9.jpg [1] => gallery10.jpg [2] => gallery11.jpg [3] => gallery12.jpg ) it did arrange my images. but i'm not quite sure how i'm supposedly going to slice that result so that I can display each images like what i did on my previous code.
  6. I have made a code that will retrieve all photos from a folder. It's working fine. The only problem is, the images are not arrange properly. My images are named this way: gallery1.jpg gallery2.jpg gallery3.jpg gallery4.jpg gallery5jpg gallery6.jpg gallery7.jpg gallery8.jpg gallery9.jpg gallery10.jpg gallery11.jpg gallery12.jpg so when i have the images displayed, instead of being arranged that way, they appear in this arrangement: gallery1.jpg gallery10.jpg gallery11.jpg gallery12.jpg gallery2.jpg gallery3.jpg gallery4.jpg gallery5jpg gallery6.jpg gallery7.jpg gallery8.jpg gallery9.jpg Here's the code: <?php $path = "..".$_SERVER['REQUEST_URI']."images/stories/mygallery/thumbs/"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if(!in_array($file, array("index.php","..","."))){ //explode to include only images $explodefile = explode(".", $file); if(in_array($explodefile[1], array("jpg","png","gif"))){ $fileList[] = $file; } } } closedir($dir_handle); $i = 0; while($fileList[$i] != ""){ echo "<li><a href='http://localhost/mysite/galleryview'><img src='".$_SERVER['REQUEST_URI']."images/stories/mygallery/thumbs/{$fileList[$i]}'></a></li>"; $i++; } ?> How can I arrange the images so they appear by their filenames accordingly (following their numbers) like this: gallery1.jpg gallery2.jpg gallery3.jpg gallery4.jpg gallery5jpg gallery6.jpg gallery7.jpg gallery8.jpg gallery9.jpg gallery10.jpg gallery11.jpg gallery12.jpg Thank you in advance!
  7. Yay yay!! It worked! Thanks so soo much for your help. I really truly appreciate it. It's been driving me nuts for days but finally it's working already. I'm so happy. Thanks!
  8. Using ProjectFear's code.. here's what page 1 shows: http://img208.imageshack.us/img208/698/79629043on9.jpg and when I click on page 2, it shows the same thing and not the next 10 images: http://img177.imageshack.us/img177/9435/87194614ej0.jpg Anybody please please help me
  9. Hi! Thanks for your reply. I tested your code and I didn't get errors but when I click on the next page, it doesn't load the next 10 list of files that are supposed to show on page 2, but instead it retains the 10 list of files that were loaded on page 1.
  10. Hi! Thanks so much for helping. I tried it, but I am getting this error "Parse error: syntax error, unexpected '-', expecting '}' in /home/site/public_html/v1/img/gallery.php on line 39" line 39 is this: echo "<a href='?page={$page-1}'>Back 1 page</a> <a href='?page={$page+1}'>Forward 1 page</a>"; I think it's because of the {$page-1} but what should I do about it? And also, I tried to remove the -1 and +1 just to see how it looks, it seems like 10 additional checkboxes are being added on the form: http://img516.imageshack.us/img516/354/imghy1.jpg
  11. Hi! Im new with PHP and I have found a php code that would display images from a certain directory from my server and have a checkbox next to them so the user can select which image to delete.. What I want is to be able to paginate the displayed images. Can anyone please help me? Here's my code: This is the code where the form appears with the images and their corresponding checkbox <?php $path = "/"; $dir_handle = @opendir($path) or die("Unable to open folder"); ?> <form name="form1" method="post" action="gallery_post.php"> <?php while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue; //explode to include only images $explodefile = explode(".", $file); if($explodefile[1] != "jpg" && $explodefile[1] != "gif" && $explodefile[1] != "png") continue; echo "<input type=CHECKBOX name='Files[$file]' value='y'>"; echo "<a href='http://www.mysite.com/$file' target='_blank'>$file</a><br />"; } closedir($dir_handle); ?> <input name="delete" type="submit" id="delete" value="Delete"> </form> This is the gallery_post.php which handles the form <?php $path = "/"; $dir_handle = @opendir($path) or die("Unable to open folder"); if($_POST['delete']){ foreach($_POST[Files] as $name => $value) if($value == "y"){ unlink ($path."/".$name); } echo "Image(s) successfully deleted. <a href='gallery.php'>Click here to go back.</a>"; } ?> The displaying of images and deleting is working fine but I really have no idea how to divide them into pages. Can anyone here please help me? Thanks so much !
  12. Hi Cook, I rechecked my Select query and you are right! Thanks muchos! It's now working
  13. I have been trying to retrieve all rows from a table by using the mysql_fetch_array function but I always get this "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource" error. I am using PHP verison 4.3.11 and Mysql version 4.1.13-standard Does my php or mysql version have anything to do with this? because it does work when I was still using an older version of mysql on my host before.. Please help! I've been trying to figure it out, but I cant. What should I do about this? Thanks!
×
×
  • 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.