I'm a beginner with php/MySQL, but I'm eager to learn and have started on a project to learn. I try to do practical things, things that I might use on a website (hobby).
The project is to make a system for adding articles to a site. I’ve made a form that allows me to write a full article for a webpage. (header, introduction, body copy.. aso) The form also includes an upload of a picture, which is stored in the SQL database. ( as a blob)
The problem comes when I want to get this full article out to a web page again; I manage to get all writings (text), but not the pictures. In phpMyAdmin I see that the pics are successfully uploaded to the DB.
Let's call the database "articles", and it includes:
navn // name on the one's inputting data
dato //date the data is inputted
header // heading on the article
ingress // introduction
innlegg // body copy
bildetekst // text for under picture
name //name on file eks: portrett.jpg
TYPE // image/jpg image/gif aso
DATA //images file stored in a mediumblob
I use this code to output my content:
while ($rad = mysql_fetch_array($get))
$id = $rad["id"];
$navn = $rad["navn"];
$dato = $rad["dato"];
$header = $rad["header"];
$ingress = $rad["ingress"];
$innlegg = $rad["innlegg"];
$bildetekst = $rad["bildetekst"];
$name = $rad["name"]; // name of file, like porteret.jpg shall be used as alt trext: alt="$name"
echo "<img src=\"image.php?id=$id\" alt=\"$name\" width=100 align=center>\n";
//the line above does not work, and that's the problem.
echo "<p class=\"author\">Updated by: $navn $dato</p>\n<hr>\n";