Jump to content


Photo

Adding file types for display


  • Please log in to reply
2 replies to this topic

#1 kd83

kd83
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 27 April 2006 - 07:01 PM

Here is a copy of my code...

<?php
print ("<link href='style.css' rel='stylesheet' type='text/css'>");
//-- User Configured Data
$current_dir = 'images/press';
//-- Read the directory and display the results.
$dir = opendir($current_dir);
print( "<table height=350 id='middleRow' cellspacing=5 cellpadding=5 border=0><tr>");
while ( $f = readdir($dir) )
{
$ext = substr($f,-4);
if ( $ext == ".jpg" ){
$pf = explode('.',$f);
print ("<td height=350 valign=middle><a href='/pdfs/" . $pf[0]. ".pdf' target='_blank'>");
print ("<img src='/images/press/" . $f ."' width=210 height=225 border=0 /></a></td>");
}
}
closedir( $dir );
print ("</tr></table>");
?>

Right now, this program grabs appropriately named gifs and lines them up with their couterpart PDF. The lady who I work for now wants to put up an image that links up 2 video links. Logistically it makes sense to link up the new images to create another page and place my video options there. Unfortunately, I am not very experienced with PHP and I am not the original designer, so I am seeking some advice. How can I add a link to the latest image that isn't a pdf and is rather a link to another page?

Thanks everyone!
Kristin


#2 kd83

kd83
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 28 April 2006 - 03:58 AM

Hey Everyone, I thought I'd update incase anyone else wants to do this...actually it was really easy to modify, I just had to think about it a lot.
[!--coloro:#333399--][span style=\"color:#333399\"][!--/coloro--]<?php
print ("<link href='style.css' rel='stylesheet' type='text/css'>");
//-- Array definitions
$current_dir = 'images/press';
$files = array();
$pf = array();
$pdf = array();
//-- Read the directory and display the results.
$dir = opendir($current_dir);
while ( $f = readdir($dir) )
{
$ext = substr($f,-4);
//searches for specific extentions and adds the files to the arrays. if you want to add a new extention, just type or $ext == ".whateverextention" inside the ()
if ( $ext == ".pdf" or $ext == ".mov" or $ext == ".wmv" ){
//f=extention
$pf = explode('.',$f);
//files=full file name
$files[] = $f;
//pdf=filename = extention
$pdf[] = $pf[0];
}
}
closedir( $dir );
//sorts by filename numerically
rsort($pdf);
rsort($files);

print( "<table height=350 id='middleRow' cellspacing=5 cellpadding=5 border=0><tr>");
for ($i = 0; $i < count($files); $i++){
//references(prints) the link to the full file
print ("<td height=350 valign=middle><a href='/images/press/" . $files[$i]. "' target='_blank'>");
//prints the thumbnail
print ("<img src='/images/press/thumbs/" . $pdf[$i] .".gif' border=0 /></a></td>");
}
print ("</tr></table>");
?>
[!--colorc--][/span][!--/colorc--]

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 28 April 2006 - 04:16 AM

good job m8
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users