Jump to content

Archived

This topic is now archived and is closed to further replies.

kd83

Adding file types for display

Recommended Posts

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

Share this post


Link to post
Share on other sites
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--]

Share this post


Link to post
Share on other sites

×

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.