Hiya!
I was advised to store image paths within databases, instead of storing within a field the image itself.
I am at the stage where I want to make use of that image path and display an image in a webpage using PHP.
I have two scripts. This is the first:
Code:
<?php
include ('common_db.php');
$link_id = db_connect();
$query = "SELECT * FROM Article";
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
?>
<h1>News Stories</h1>
<?php
while ($row = mysql_fetch_array($result)) {
?>
<p><a href="ViewArticle.php?action=Article&ID=<?php echo $row['ArticleID'];?>"><?php echo $row['ArticleTitle'];?></a></p>
<?php
}
?>
When you click the link (which is the title of the story), you go to script 2:
Code:
<?php
include ('common_db.php');
$link_id = db_connect();
$query = "SELECT * FROM Article, Image WHERE Article.ArticleImage = Image.ImageID AND ArticleID = '" . $_GET['ID'] . "'";
$result = mysql_query($query) or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array($result)
?>
<p><?php echo $row['ArticleTitle']; ?></p>
<p><?php echo $row['ArticleDate']; ?></p>
<p><?php echo $row['ImageLoc']; ?></p>
<p><?php echo $row['ArticleEntry']; ?></p>
<p><a href="ArticleLinks.php">back</a></p>
The field "ImageLoc" is the path to image stored on the server.
Only problem is, the actual path is displayed, not the image.
What am I doing wrong?
Any help appreciated!