tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
I'm trying to design an image database like this:
[url]http://hitchcock.itc.virginia.edu/Slavery/return.php?categorynum=1[/url]
so far i wrote my php code as:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "myID", "myPSW") or die(mysql_error());
mysql_select_db("image") or die(mysql_error());
$result = mysql_query("SELECT * FROM tbimg")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>image</th> <th>description</th><th>price</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 $row['id'];
echo "</td><td>";
header("Content-type: image/jpeg");
echo <img src=\"{$row['image']}\">
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo $row['price'];
echo "</td></tr>";
}
echo "</table>";
?>
are your images url's stored in the table? view the source of your page and see if img src="" has the same url as what you have in the database, also check if that url is valid
<?php
// Make a MySQL Connection
mysql_connect("localhost", "myID", "myPSW") or die(mysql_error());
mysql_select_db("image") or die(mysql_error());
$result = mysql_query("SELECT * FROM tbimg")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>image</th> <th>description</th><th>price</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 $row['id'];
echo "</td><td>";
echo "<img src=".$row['image'].">";
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo $row['price'];
echo "</td></tr>";
}
echo "</table>";
?>
Haven't tested it...
echo <img src="{$row['image']}\">
there's no "; at the end
<?php
// Make a MySQL Connection
mysql_connect("localhost", "myID", "myPSW") or die(mysql_error());
mysql_select_db("image") or die(mysql_error());
$result = mysql_query("SELECT * FROM tbimg")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>id</th> <th>image</th> <th>description</th><th>price</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 $row['id'];
echo "</td><td>";
echo "<img src=".$row['image'].">";
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo $row['price'];
echo "</td></tr>";
}
echo "</table>";
?>
Haven't tested it...
echo <img src="{$row['image']}">
there's no "; at the end
thank you.
haha i went to phpfreaks.com and posted the same question and some guy said to add the header...
Anyways, I think I solved the problem.
before I only inserted the link address cause I thought I could write the php code to do what I wanted.
But then I typed <img src="http://hostname/image.jpg"> and then it worked.
The only thing that baffles me is that gif's don't appear. It's clearly a valid image data on my site, but it won't appear. Oh well, I can just change'em all to jpg.