Jump to content

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>";
?>

 

If I put an exact name in the path,,, it works but pulls the same picture for every entry..I would like the pictures to dispaly like the other rows in the database,  row by row..

<?php
echo "<img src='/userimages/cars/1238640191.jpg'>";
?>

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)
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.