Jump to content

JacobRyan

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Everything posted by JacobRyan

  1. Success, thank you! Finally get what I was doing wrong.
  2. Doesn't seem to matter where I move the echo for ending the table row I seem to terminate it to earlier then I'm left with a long list of the same picture repeating based on whatever value y has. And if I leave it outside the loop then, I get a table of the same image, but I guess at least it's a table?
  3. <?php $path = "../assets/tattoos/"; $path2 = "../assets/tattoos-thumbs/"; if(isset($_POST['file']) && is_array($_POST['file'])) { foreach($_POST['file'] as $file) { unlink($path. "/" . $file) or die("Failed to delete file"); unlink($path2. "/" . $file) or die("<meta http-equiv=\"refresh\" content=\"0; url=index.php\" />"); } } ?> <form name="form1" method="post"> <?php $imageDir = "../assets/tattoos/"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue; echo "table"; echo "<tr>"; for ($y = 0; $y < 4; $y++) { echo ($x % 4 == 0) ? "</tr><tr>" : ""; echo "<td><input type='CHECKBOX' name='file[]' value='$file'><img src='../assets/tattoos/$file' style='height:auto;width:50%;' alt='$file'></td>"; $x++; } } echo "</tr>"; echo "</table>"; closedir($dir_handle); ?> That's what I have it to now. It's repeating the directory in a vertical row, then making a new one next to it.
  4. So I must be doing something wrong, it's repeating each image 50 times then starting a new table. Any idea's?
  5. Ahhh okay. The other examples I've seen a lot of people just began the <table> tag outside of the php tag. That makes much more sense now.
  6. Question, what would be the purpose of echoing the table tag if it will be just one table?
  7. Welp I won't even pretend to know where to start with your provided example.
  8. Sorry for my lack of knowledge (I'm still fairly new to PHP and kind of stumbling my way through it for now), where would I place that in my existing code?
  9. <?php $path = "../assets/tattoos/"; $path2 = "../assets/tattoos-thumbs/"; if(isset($_POST['file']) && is_array($_POST['file'])) { foreach($_POST['file'] as $file) { unlink($path. "/" . $file) or die("Failed to delete file"); unlink($path2. "/" . $file) or die("<meta http-equiv=\"refresh\" content=\"0; url=index.php\" />"); } } ?> <form name="form1" method="post"> <?php $imageDir = "../assets/tattoos/"; $dir_handle = @opendir($path) or die("Unable to open folder"); while (false !== ($file = readdir($dir_handle))) { if($file == "index.php") continue; if($file == ".") continue; if($file == "..") continue; echo "<input type='CHECKBOX' name='file[]' value='$file'>"; echo "<img src='../assets/tattoos/$file' style='height:auto;width:8%;' alt='$file'>"; } closedir($dir_handle); ?> <input type="submit" name="Delete" value="Delete"> </form> I have this code, which calls an image directory and adds a checkbox next to it, you check the boxes you wish, hit delete and the pictures are removed from the server. I need them to display in a grid view, like 4 columns by X amount of rows. Any help would be greatly appreciated.
×
×
  • 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.