View Single Post
Old May 9th, 2005, 12:37 PM   #4
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!

Last edited by Pizentios; May 9th, 2005 at 12:39 PM.
Pizentios is offline   Reply With Quote