hey, i have set up a database to store images in blobs, and i'm trying to re-produce these images in php, for a photo album
i have set the headers for the content type and i have set up the display form, however i cannot use
<? echo "<img src=$data width=\"100\">"; ?>
in my while loop because i get an error, but if i just use
<?=$data?>
then it works and shows the picture
i want to the use the top method becausei want to re-szie the images so i can display them as thumbnails
anyhelp would be great, here is my current script (for reference)
<?
session_start();
session_cache_expire(1000);
Header("Content-type: image/gif");
if ($_POST['submit']) {
if ($_POST['limit']) {
$_SESSION['limit'] = $_POST['limit'];
}
}
if (!$_SESSION['limit']) {
$_SESSION['limit'] = "10";
}
include("./includes/auth/common.php");
function thumbs() {
// FUNCTION TO SHOW THE THUMBNAILS OF ALL THE PICTURES
$limit = $_SESSION['limit']; // RETURN LIMIT SESSION
$page = $_GET['page']; // RETURN PAGE NUMBER
$query_count = "SELECT * FROM `binary_data` ORDER BY `id` DESC"; // SELECT RESULTS
$result_count = mysql_query($query_count) or die (mysql_error()); // GET RESULTS
$totalrows = mysql_num_rows($result_count); // GET NUMBER OF ROWS
if(empty($page)) {
$page = 1; // SET PAGE - 1, IF IT DOESNT EXIST
}
$limitvalue = $page * $limit - ($limit); // SET LIMIT VALUE
$query = "SELECT * FROM `binary_data` ORDER BY `id` DESC LIMIT $limitvalue,$limit "; // SELECT RESULTS
$result = mysql_query($query) or die (mysql_error()); // GET RESULTS
$count_result = mysql_num_rows($result); // COUNT NUMBER OF RESULTS
$numofpages = ceil($totalrows / $limit); // GET NUMBER OF PAGES
$from=$limit*$page-$limit+1; // FROM
$to=$from + $count_result-1; // TO
echo "<p style=\"margin-left: 3; margin-right: 3; margin-top: 0\">";
echo"<br><b>$totalrows</b> pictures in the ".$album." album";
if($numofpages>1){echo" (showing: $from - $to)";}
echo "<br><br>" ;
while ($row=mysql_fetch_array($result)) {
// PRINT THE RESULTS
$data = $row['bin_data'];
echo "<img src=\"".$data."\" width=\"100\"><br>";
}
// PRINT PAGE NUMBERS
echo "<br><table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" align=\"left\">";
// PRINT BACKWARDS LINK
if($page != 1) {
$pageprev = $page - 1;
echo("<a href=$PHP_SELF?page=1><< FIRST</a> | <a href=$PHP_SELF?page=$pageprev>< PREV</a> ");
}
// PRINT PAGE NUMBERS IF NOT 1
for($i = 1; $i <= $numofpages; $i++) {
if($numofpages>1) {
if($i == $page) {
echo(" ".$i." ");
}
else {
echo(" <a href=$PHP_SELF?page=$i>$i</a> ");
}
}
}
// PRINT FORWARD LINK
if(($totalrows - ($limit * $page)) > 0) {
$pagenext = $page + 1;
echo("<a href=$PHP_SELF?page=$pagenext>NEXT ></a> | <a href=$PHP_SELF?page=$numofpages>LAST >></a>");
}
// PRINT PAGE NUMBERS END
echo"</td></tr></table><br>";
}
thumbs();
?>
thanks 🙂