Jump to content

ethan89

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

About ethan89

  • Birthday 12/10/1990

Profile Information

  • Gender
    Male
  • Location
    United States

ethan89's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks! It works perfectly! I removed the number of directories parts of the code and made it shorter. Here is my final code: <?php $path = '.'; $no = "0"; if ($handle = opendir($path)) { while (false !== ($img = readdir($handle))) { if ($img != "." && $img != ".." && $img != "index.php") { $img = $path.'/'.$img; if (is_file($img)) $no++; } } closedir($handle); } echo "$no"; ?> SOLVED, Thanks phobic
  2. At first I thought you code worked, but it displays 1 every time.
  3. I've tried this code and a few others, but it only displays 0. I'd like the simplest working way to display the number of files in a directory. Thanks for the help! $directory = "../images/team/harry/"; $filecount = count(glob("" . $directory . "*.*")); echo $filecount;
  4. Sorry, but I said I don't have a database.
  5. I see several great PHP/MySQL paging systems on google, but how can I make a paging system when I'm just showing all images in a directory, not showing all images from a database? I have no idea how I could convert one of those mysql systems to work for my needs. Here is my code: <?php $columns = "4"; $count = "0"; echo '<div style="overflow:auto; width:500px; height:266px;"><table cellpadding="0" cellspacing="10">'; if ($handle = opendir('.')) { while (false !== ($image = readdir($handle))) { if ($image != "." && $image != ".." && $image != "index.php") { if (strlen($image) > 11) { $short = substr($image,0,11); echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$short.'...</div></a></td>'; } else { echo '<td align="center"><a href="'.$image.'" title="'.$image.'"><img src="'.$image.'" width="100" height="100"><br><div style="overflow:auto; width:100px;">'.$image.'</div></a></td>'; } $count++; if ($count == 4) { echo "</tr><tr>"; $count = 0; } } } closedir($handle); } echo "</table></div>"; ?> This code shows all images in a directory, 4 per row. I'd really appreciate some help with adding a paging feature to this. Thank you so much for the help!
  6. No prob. I'm glad you made this topic, or I would have never gotten it done myself.
  7. Never mind, I was able to edit it. I made it short and simple: <?php if (strlen($words) > 10) { $short = substr($words,0,10); echo ''.$short.'...'; // This will display 10 letters and ... (Textistool...) } else { echo 'The text that isn't too long goes here'; } ?> As you can see, it's easy to change how long you want the text to be before the ... I did notice one problem with using this code though. If one of your columns has 10 W's (WWWWWWWWWW), it's much longer than 10 a's (aaaaaaaaaa), so it still may go over to the next line . It's not a huge problem I guess. To fix this problem, I use this before the text: <div style="overflow:auto; width:100px;">TEXT HERE</div> Make it the width of your column, and those W's will just be cut off instead of go to the next line, but you won't be able to see the "..." because it will be cut off too..
  8. Since you've created this topic, I'm really interested in adding this to my site as well. I found this code online. It appears to be exactly what we're looking for, but it needs to be edited some: <?php $file = "Hellothisfilehasmorethan30charactersandthisfayl.exe"; function funclongwords($file) { if (strlen($file) > 30) { $vartypesf = strrchr($file,"."); $vartypesf_len = strlen($vartypesf); $word_l_w = substr($file,0,15); $word_r_w = substr($file,-15); $word_r_a = substr($word_r_w,0,-$vartypesf_len); return $word_l_w."...".$word_r_a.$vartypesf; } else return $file; } ?> One problem with this code is that it puts the "..." in the middle of the words, which is good if you want to see the beginning and end of the line, but I want the "..." at the end of the words. Will you do me a favor and give me your edited version if it works for you? I'm not that good at PHP
  9. Thanks for your help, Abra. It turns out all I needed to do was change http://www.EXAMPLE.com/users/member.php to ../member.php. I love it when there is such a simple solution to a seemingly huge problem
  10. Oh.. I put member.php in the same folder as index.php just to test that it works and it does. I guess the http:// was messing it up like you said. I have a problem though. I can't put member.php in the same folder as index.php later. How can I include member.php in index.php without using http://www if it's one folder back? :-\
  11. I tried doing user/member.php and /user/member.php and it can never find the directory so I had to do the whole URL. Do you think this is my problem? Maybe it's not possible to do it without the whole URL since member.php is in users/ and index.php is in users/*username*/ I defined $member in index.php
  12. I've had this problem too. What I do is put this around the text: <div style="overflow:auto; width:100px;">text goes here</div>. You have to set the width to the same width as your column though. The problem is, this doesn't add the "..." that you want.
  13. included in index.php? I hope that wasn't confusing. Here is my complete problem: I have one page called index.php that contains: <?php $member = substr(dirname($_SERVER['PHP_SELF']), ; // This is the name of the directory include 'http://www.EXAMPLE.com/users/member.php'… ?> I have another page called member.php (the one that is included) that contains: <?php echo "$member"; ?> There is only one problem. The above code doesn't work. It won't display $member. How can I fix this? Setting a cookie didn't work. Maybe because member.php is included in index.php and I'm not going from index.php to member.php. Thank you very much for the help! I appreciate people taking their time to help other people.
  14. Oh never mind, it works perfectly. I was doing something wrong when I tested it last time. Thanks so much guys. Solved
×
×
  • 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.