Quote:
|
no it would not work it would just put the string in there.
|
it wouldn't put the string into it. it would put the result from the query into the img tag. which would look like "result index 0" or something like that.
if $item_image held the path you could do it.
this is how i would write it.
Note: This is code for a postgresql db, but you are probally using mysql.
[PHP]
//connect to the db
$pgConnection = pg_connect("dbname=users user=me password=foobar");
$sql = "select item_image from store_items where item_title = mshirt";
//then with your connection to the db, execute the query above:
$res = pg_query($pgConnection, $sql);
//now check to see if the query returned anything.
if (pg_num_rows($res) <> 0)
{
//now we can loop and creat output table.
for ($x=0; $x<pg_num_rows($res); $x++)
{
$data = pg_fetch_object($res, $x);
$display_table .= "
<td><a href=\"mshirt.php\"><img src=\"" . $data->item_image . "\" /></a></td>";
}
}
else
{
//error message:
?>
<center>
<b>There are no shirt images.</b>
</center>
<?PHP
}
[/PHP]
anyways, if you are using mysql, you'll have to do a little research on what functions you'd need to use.