Jump to content

still cant get image to dispaly from image path


justAnoob

Recommended Posts

Someone told me that the path that is saved in MySQL is not the path that you would call to display the image. But then I read differently on google. So right now the path below is the path that is saved in MySQL. What else could I try. I just get a little box with an "x" inside it instead of a picture. Here is my code. Any help would be much appreciated. Thanks.

<?php
mysql_connect("*****","******","*******8"); 
mysql_select_db("*****");
$sql = mysql_query("SELECT imgpath, x, xx, xxx FROM students");

echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>";
echo "<tr> <td><H3>Image </h3></td> <td><H3>x</H3></td>    <td><H3>xx</H3></td><td><H3>xxx</H3></td></tr>";
// grab all til no more
while ($row = mysql_fetch_array($sql))
{
// dispaly in table format
echo "<tr><td>";
echo "<img src='/userimages/cars/*.jpg,*.png,*.gif'>";
echo "</td><td>";
echo $row['x'];
echo "</td><td>";
echo $row['xx'];
echo "</td><td>";
echo $row['xxx'];
echo "</td></tr>";
}
echo "</table>";
?>

 

I take it this is what you are after:

 

$images = glob($row['imgpath']. "{*.gif, *.jpg, *.png}", GLOB_BRACE);

foreach ($images as $image) {
    echo "<img src='{$image}' />"; // either that or echo "<img src='{$row['imgpath']}{$image}' />"; (whichever one works)
}

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.