Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/8571-adding-file-types-for-display/
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--]
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.