cragllo
03-04-2005, 11:26 PM
ok, i have this code to make thumbnails:
<?php
import_request_variables("gP", "");
$t_width = 100;
$img = $_SERVER['QUERY_STRING'];
// get and display jpeg images
if(stristr($img,".jpg")){
header("Content-type: image/jpeg");
$srcimage = imagecreatefromjpeg($img);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
$newh1= $height / $width;
$newh2= $newh1 * $t_width;
$destimage = imagecreatetruecolor($t_width,$newh2);
imagecopyresized($destimage,$srcimage,0,0,0,0,$t_width,$newh2,$width,$height);
ImageJPEG($destimage);
ImageDestroy($destimage);
}
?>
And use this code to display the images:
<?
$record = $_GET['recid'];
if(empty($record))
$record = 1;
$query = "SELECT * FROM screenshots";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
// the number of records, record number to start from and number of pages
$numrows = mysql_num_rows($result);
$pagestart = ($record * $pagecount - ($pagecount));
$numpages = $numrows / $pagecount;
if(($numrows % $pagecount) != 0)
$numpages += 1;
$query = mysql_query("SELECT * FROM screenshots ORDER BY id DESC LIMIT $pagestart, $pagecount ");
?>
<font size="2" face="Arial">
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
Show <select name="items_per_page" value="<?= $pagecount;?>">
<option value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>
<option value="100">100</option>
</select> downloads per page.
<input type="submit" name="Submit" value="GO">
</form>Go to page:
<?
// this creates the pagination links
for($i=1; $i < $numpages; $i++) {
echo ' <a href="' . $_SERVER['PHP_SELF'] . '?recid=' . $i . '">' . $i . '</a> ';
}
?>
</font><br>
<?
while($var = mysql_fetch_array($query)){
?>
<a href="screenshot.php?id=<?=$var[id]?>"><img src="thumb.php?screenshots/<?=$var[image]?>" border="0"></a>
<?
}
?>
I also have this code to display images in a folder...
<?
$files = Array();
$path = "images/animations";
$dh = opendir($path);
while ($file = readdir($dh)) {
if (!is_dir($path."/".$file)) {
if (is_file($path."/".$file)) {
if (($file!=".") && ($file!="..")) {
$files[] = $file;
}
}
}
}
closedir($dh);
asort($files);
foreach($files as $index=>$file) {
echo "<img src=\"images/animations/".$file."\">\n";
}
?>
What I want to do is, display all image in a folder, as thumbnails. And each image is a link to the full sized image. (not using a database)
Also to display 20 per page and have pagination...
So if someone could explaing how, or give exampleas, or show me how, that would be great.
Thank you,
Craig.
<?php
import_request_variables("gP", "");
$t_width = 100;
$img = $_SERVER['QUERY_STRING'];
// get and display jpeg images
if(stristr($img,".jpg")){
header("Content-type: image/jpeg");
$srcimage = imagecreatefromjpeg($img);
$width = imageSX($srcimage);
$height = imageSY($srcimage);
$newh1= $height / $width;
$newh2= $newh1 * $t_width;
$destimage = imagecreatetruecolor($t_width,$newh2);
imagecopyresized($destimage,$srcimage,0,0,0,0,$t_width,$newh2,$width,$height);
ImageJPEG($destimage);
ImageDestroy($destimage);
}
?>
And use this code to display the images:
<?
$record = $_GET['recid'];
if(empty($record))
$record = 1;
$query = "SELECT * FROM screenshots";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
// the number of records, record number to start from and number of pages
$numrows = mysql_num_rows($result);
$pagestart = ($record * $pagecount - ($pagecount));
$numpages = $numrows / $pagecount;
if(($numrows % $pagecount) != 0)
$numpages += 1;
$query = mysql_query("SELECT * FROM screenshots ORDER BY id DESC LIMIT $pagestart, $pagecount ");
?>
<font size="2" face="Arial">
<form name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
Show <select name="items_per_page" value="<?= $pagecount;?>">
<option value="20">20</option>
<option value="40">40</option>
<option value="60">60</option>
<option value="100">100</option>
</select> downloads per page.
<input type="submit" name="Submit" value="GO">
</form>Go to page:
<?
// this creates the pagination links
for($i=1; $i < $numpages; $i++) {
echo ' <a href="' . $_SERVER['PHP_SELF'] . '?recid=' . $i . '">' . $i . '</a> ';
}
?>
</font><br>
<?
while($var = mysql_fetch_array($query)){
?>
<a href="screenshot.php?id=<?=$var[id]?>"><img src="thumb.php?screenshots/<?=$var[image]?>" border="0"></a>
<?
}
?>
I also have this code to display images in a folder...
<?
$files = Array();
$path = "images/animations";
$dh = opendir($path);
while ($file = readdir($dh)) {
if (!is_dir($path."/".$file)) {
if (is_file($path."/".$file)) {
if (($file!=".") && ($file!="..")) {
$files[] = $file;
}
}
}
}
closedir($dh);
asort($files);
foreach($files as $index=>$file) {
echo "<img src=\"images/animations/".$file."\">\n";
}
?>
What I want to do is, display all image in a folder, as thumbnails. And each image is a link to the full sized image. (not using a database)
Also to display 20 per page and have pagination...
So if someone could explaing how, or give exampleas, or show me how, that would be great.
Thank you,
Craig.