Hi!
Before my application would only store the
filename into the database, and the file content itself would be stored into a directory with 777 rights.
I tried to incorporate a piece of code into my application code, to upload the files into the database.
But I have a little problem. How to read the files from the database?
I would like to display several files onto one page. My application is a photo gallery.
I end up with this piece of code, but it doesn't work.
So if you have any time for a little suggestion...
Thanks
Stephane/Stockholm
while ($myrow = db_fetch_row($result)) {
$id = $myrow["id"];
$image = $myrow["image"];
$filesize = $myrow["filesize"];
$filetype = $myrow["filetype"];
$filecontent = $myrow["filecontent"];
// Remove the carriage returns from the text
$description = str_replace("\n", "", $description);
if ($image != "") {
$imgstr = $filecontent;
} else {
$imgstr = " ";
}
$strcell = "\n<TD VALIGN=TOP><TABLE><TR><TD WIDTH=$itemWidth>";
$strcell = $strcell . $imgstr . "<BR>$fontxs";
if (!empty($description)) {
$strcell = $strcell . $description . "<BR>";
}
$strcell = $strcell . "<B>Ref: </B>" . $reference . "<BR><B>Price: </B>" . $price . " " . $currency . $endfont;
$strcell = $strcell . "</TD></TR></TABLE></TD>";
if ($cellnb > 2) {
$str = $str . "</TR><TR>" . $strlink;
$strlink = "";
}
$strlink = $strlink . "<TD VALIGN=TOP>";
$strlink = $strlink . "<A HREF='itemupdate.php?id=" . urlencode($id) . "'>Update" . "</A> ";
$strlink = $strlink . "<A HREF='itemdelete.php?id=" . urlencode($id) . "'>Delete" . "</A></TD>";
// Allow a certain number of cells in a row
if ($cellnb > 2) {
$str = $str . "</TR><TR><TD> </TD></TR><TR>";
$cellnb = 0;
}
$cellnb = $cellnb + 1;
$str = $str . $strcell;
}
$str = $str . "</TR><TR>" . $strlink;
$str = $str . "</TR>";
$str = $str . "\n</TABLE>";
// Output the header
require("header.php");
// Output the body
printPage($str, "");
// Output the footer
require("footer.php");