how do i display an image from a session variable in php?

  • Thread starter Thread starter Mr E
  • Start date Start date
M

Mr E

Guest
i have an SQL database, inside the database holds basically a string field with the image name.

the PHP code then finds the image in the following way

echo " <img src='./thumb/". $row['Thumbimage']."'>

however hidden fields cannot pass the images across, so i needed to devise a new way to do this. so i thought the best way to do this would be to get all the images that get passed along in a querey and then display the images this way, only i've gotten a bit stuck and need assistance. this is the code i have

<?php



echo ("<table border=1>");
echo ("<th id='tablestyle'> Door Name</th>");
echo ("<th id='tablestyle'> Quantity</th>");
echo ("<th id='tablestyle'>Individual Price</th>");
echo ("<th id='tablestyle'>Image</th>");
echo ("<th id='tablestyle'>Sub Total</th>");


echo ("<tr>");


foreach ($_SESSION as $key=>$val)
{

$index = stripos($val, "+");
$quantity = substr($val, 0, $index);
$price = substr($val,$index+1);

$sql = mysql_query("SELECT Thumbimage, DoorName FROM tblpricelist where DoorName = $index");

$image = $row['Thumbimage']; <---- this is where i would like the thumb image to be assigned a variable name as shown, only this doesn't work

echo "<td id='tablestyle2'> $key </td>";
echo "<td id='tablestyle2'> $quantity </td>";
echo "<td id='tablestyle2'> £$price </td>";
echo "<td id='tablestyle2'><img src='./thumb/". "$image"."'/>
\ THE ABOVE LINE IS WHERE I WOULD LIKE THE IMAGE TO BE PLACED // (sorry for caps)


</td>";
$sum_total=$quantity*$price;
echo "<td id='tablestyle2'>£$sum_total</td>";
$sum_total2=$sum_total+$sum_total;
echo "<td id='tablestyle2'>£$sum_total2</td>";
echo "</tr>";


}

echo ("</tr>");
echo ("</table>");
?>


</div>


so far this method displays nothing. how would i get it to display the image?
 
Back
Top