Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Oikofugic

  • Rank
  1. Hi I have used in the past search.php?sl=y on a link to the page, and in the page I would use if($_GET[$sl]=='y'){ Show somw stuff here } This was good in php 5.6, but I'm in the process of upgrading my code to the newer version, and am looking for an updated way to acheive this. Help, pointers examples Thanks in advance. Paul
  2. Thanks for clearing it up for me. I understand now <?php $dir = "pics/"; // Open a directory, and read its contents if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ if (is_file($dir.$file)) { echo '<img src=" '.$dir.$file.' " width="120px" height="120px"/>'; } } closedir($dh); } } ?>
  3. Hi ginerjim, as I previously posted I have it working, with help from the link provided by requinix, then Berand popped back with his RTFM which I initially thought was an abbreviation for something useful that I would find on that page. I copied his code and tried to implement it into what I had, assuming it would negate the need to strip out the dots, but ended up with Undefined variable warning. It might have ultimately been for a more elegant solution Barand suggested, but as I had working anyway, I figured a partial solution with no explanation was not at this time necessary. This is what I was trying, but as you can no doubt tell I'm getting muddled <?php $dir = "pics/"; $file =""; // Open a directory, and read its contents if (is_file($dir.$file)) { if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ echo "<img src=\"$dir$file\" width=\"120px\" height=\"120px\"/>"; } closedir($dh); } } ?> I have tried various combinations etc So attempting to defile $file, but not quite sure as to why
  4. Hi Barand, Have tried with your suggestion, no joy unfortunately, undoubtedly my lack of understanding, but thanks anyway..
  5. Thanks requinix, It's still foo bar tbh, but got it working. Ta <?php $dir = "pics/"; $dh = opendir($dir); while (false !== ($file = readdir($dh))) { $pos = strrpos($file, '.'); if (false !== $pos && strlen($file) > $pos + 1) { $ext = substr($file, $pos + 1); echo '<img src="pics/'.$file.'" width="120px" height="120px"/>'; } } ?>
  6. Thanks for your reply, but there is only one image in the folder and nothing else.
  7. Hi all, I'm trying to echo all the files in the folder 'pics' <?php $dir = "pics/"; // Open a directory, and read its contents if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh)) !== false){ echo '<img src="pics/' .$file . '" width="120px" height="120px" />'; } closedir($dh); } } ?> The above code outputs the following. (there is only one image in the folder) So the code gets the image correctly and works with multiple images in the folder, but also produces two broken pathways at the beginning. <img src="pics/." width="120px" height="120px" /><img src="pics/.." width="120px" height="120px" /><img src="pics/j1.jpg" width="120px" height="120px" /> My question is why, I can't figure out what is happening. Any pointers or explanations would be appreciated. Cheers for your time. Paul
  • 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.