Jump to content

PHP Variables and Image load


tpohara

Recommended Posts

Hi, I'm trying to edit some rather complicated code, but essentually I am attempting to load an image into a PHP page, based on a SQL query. My site is working with Oracle and is working fine. I wish to add one function where I load an image into a php page based on the name of a file stored in a relational database, the image is located on a local hard drive. The query part is working fine as the top portion is getting the name and placing it into the table. I am attempting to insert the database result into the field where the image would normally just be entered. When I attempt to pass the variable into the string for the the image portion it will not work. Any ideas, any help would be grateful. Thanks. Clealry I am missing something basic here. The path is displayed in the table but will not get drawn in to the image section.

 

Sample of the code:

 

<!-- This page gets the information to display for a shelf and shows a picture of it. -->

<HTML>

<?php

import_request_variables("gpc");

$bay = $_POST['bay'];

 

 

//query to get picture path information

$qry = "select * from shelf_rec shelf, database.model part, database.nodes node

where node.object_id = '$shelf'

and node.part_id = part.part_id

and shelf.object_id = node.object_id";

$stmt = OCIParse($conn, $qry);

OCIExecute($stmt);

while ($row = oci_fetch_array ($stmt))

{

$s_photo_path = $row['PHOTO_PATH'];

}

 

   

//display shelf information

// GET A TABLE IN HERE............

 

    echo"<TR>";

    echo "<TD><FONT COLOR='PURPLE'><B>Photo Path:</B></FONT></TD>";

    echo "<TD><FONT COLOR='red'><I>&nbsp &nbsp &nbsp &nbsp &nbsp $s_photo_path</FONT></TD>";

    echo"</TR>";

    echo"</table>";

    echo"<br clear='left'>";

 

?>

 

 

<CENTER><H2>

<img border="0" src="$s_photo_path" width="284" height="144">

</CENTER></H2>

<center>

<FONT SIZE="3">$s_photo_path</FONT>

<br>

<br>

</center>

</BODY>

 

 

</HTML>

 

 

Link to comment
https://forums.phpfreaks.com/topic/242161-php-variables-and-image-load/
Share on other sites

You need to wrap in php tags and also echo the variable

 

as one example

 

from this:

<img border="0" src="$s_photo_path" width="284" height="144">

 

to this:

<img border="0" src="<?php echo $s_photo_path;?>" width="284" height="144">

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.