Jump to content

Help displaying images in loop stored in mysql database row


bdarilek

Recommended Posts

Help!! I'm a newbie with a problem displaying my images that are stored in the database.

 

I can upload and actually view an image but from only the first row.

 

The information from the other rows displays just fine. I just can't get the right image to display with the rest of the corresponding fields. It only show the image from the first record.

 

Below is my code:

 

<?php

 

$dbcnx = mysql_connect("localhost", "xxxxxxxx", "xxxxxx");

mysql_select_db("xxxxxxx");

 

$request = @mysql_query("select * from profiles");

while ($row = @mysql_fetch_assoc($request)) {

 

 

if ($_REQUEST[gim] == 1) {

        header("Content-type: image/jpeg");

        print $row['c_photo'];

        exit ();

        }

 

echo

"<img src=?gim=1><br>".

"Name :{$row['c_first']} {$row['c_last']}<br>".

"Email :{$row['c_email']} <br>".

"Phone :{$row['c_phone']} <br><hr><br><br><br>";

 

 

}

 

 

?>

 

Thanks for any help in advance.

Link to comment
Share on other sites

Sorry, I wasn't being very clear:

 

Upload image to a directory on the actual file system.

Take note of where it is and what it is, and store it in your database.

 

Then, for example:

$get_image = mysql_query("SELECT image_directory FROM images WHERE image_id = $example") or die(mysql_error());
$image_directory = mysql_fetch_row($get_image);
echo '<img src="'.$image_directory.'" alt="Whatever, maybe a caption?" />';

 

The column image_directory could hold the location of an image on your web server. So, image_directory could be:

 

"images/example.gif".

 

Link to comment
Share on other sites

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.