You are here: Re: Display pictures corresponding to database entry. « All PHP « IT news, forums, messages
Re: Display pictures corresponding to database entry.

Posted by robert on 05/15/06 17:26

| I display the personal
| information form the database in a table amd now want to display the
| corresponding picture with the individual information in the table.
|
| This is the page with the indiviual info without the pictures.
|
| http://sadcma.com/Missions/DistrictMissionary.php

i assume your question is "how do i go about doing this?"

here's what i do...hth...and, sorry for the wrapping below.


========= usage

// $queryString: ex., ?fileName=doofus.jpg&maxSize=200

<a
href="<?= $site->uri ?>get.file.php<?= $queryString ?>"
style="font-size:12pt;"
>
<img
src="<?= $site->uri ?>get.thumb.nail.php<?= $queryString ?>"
alt="<?= $record['DESCRIPTION'] ?>"
title="Click To Open: <?= $record['DESCRIPTION'] ?>"
/>
</a>


========= get.thumb.nail.php

// site.cfg.php contains info about the site (paths, env. info, etc.)
// functions.inc.php defines functions (ex., isSupportedMedia, etc.)

<?
require_once 'site.cfg.php';
require_once $site->includeDirectory . 'functions.inc.php';
$fileName = $_REQUEST['fileName'] ? $_REQUEST['fileName'] :
$_REQUEST['altImage'];
$maxSize = $_REQUEST['maxSize'] ? $_REQUEST['maxSize'] : 200;
$filePath = $site->imagesDirectory;
if (!(isSupportedImage($fileName) || isSupportedMedia($fileName)))
{
$fileName = isSupportedMedia($fileName) ? 'media.jpg' :
'document.jpg';
$filePath = $site->imagesDirectory;
}
$fileData = @file_get_contents($filePath . $fileName);
$originalImage = @imagecreatefromstring($fileData);
@list($imageWidth, $imageHeight, $imageType, $imageAttributes) =
@getimagesize($filePath . $fileName);
$newImageHeight = $imageWidth < $maxSize ? $imageHeight : ($imageHeight /
$imageWidth) * $maxSize;
$newImageWidth = $imageWidth < $maxSize ? $imageWidth : $maxSize;
$thumbNail = @imagecreatetruecolor($newImageWidth, $newImageHeight);
@imagecopyresampled(
$thumbNail,
$originalImage,
0,
0,
0,
0,
$newImageWidth,
$newImageHeight,
@imagesx($originalImage),
@imagesy($originalImage)
);
@imagejpeg($thumbNail);
@imagedestroy($thumbNail);
@imagedestroy($originalImage);
?>

========= get.file.php

<?
require_once 'site.cfg.php';
$fileData = '';
$fileName = $_REQUEST['fileName'];
$filePath = $site->uploadBaseDirectory;
if ($fileName != ''){ $fileData = @file_get_contents($filePath .
$fileName); }
header('pragma: public' );
header('expires: 0' );
header('cache-control: private', false );
header('cache-control: must-revalidate, post-check=0, pre-check=0' );
header('content-disposition: attachment; filename="' . $fileName . '"' );
header('content-size: ' . count($fileData) );
header('content-transfer-encoding: binary' );
header('content-type: application/octet-stream' );
echo $fileData;
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация