Hi I was hoping someone could help me with a image databasing problem that I have come accross.
I can upload images and display their names in a table list.
I have made it so each image name is a hyperlink to a page that displays
the image which has been selected. The only problem is that the image which is displayed is always the first image in the database, even though I am selecting different image names from the list.
here is my code:
This is code which displays my image names in a list
<?php
// Make a MySQL Connection
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("cook_book") or die(mysql_error());
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM upload")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Recipe Name</th></tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>";
//echo "<img src=' ".$row['RecipeName']." '>";
echo $row = '<a href="'."TRY.PHP".'">'.$row['RecipeName'].'</a>';
echo "</tr></td>";
}
echo "</table>";
?>
</body>
This is the code which is supposed to display the correct image that has been selected not just the first one in the database.
This file is named TRY.PHP
<?php
$conn = mysql_connect("localhost","root","");
$db = mysql_select_db("cook_book")
or die(mysql_error());
$query = mysql_query("SELECT * FROM upload");
while($row = mysql_fetch_array($query)){
echo $row['content'];
}
?>
Any help would be greatly appreciated.