Jump to content


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


Viewing Images

Recommended Posts

Hello, I am very very new to all this and am building a website.

I have managed to Create a mySql Database, I have managed to upload information into the database and upload a file to the image directory.

for example
Table name is employees
User inputs --
Name goes to Name Field
Email goes to Email Field
Phone goes to Phone Field
Photo filename goes to Photo Field and the Image goes to my Upload Dir.

When I do a search I can enter the name and it displays all info in the Database, but I cant seem to put a code in to view the picture too.

Can anyone help my stupidity.


Share this post

Link to post
Share on other sites
well in your script after it retrieves the info you just make an img tag.

let's say your script looks something like this:
$name = $_POST['name'];

$sql = "select * from employees where Name='$name'";
$result = mysql_query($sql);
$info = mysql_fetch_array($result);

echo "Name: " . $info['Name'] . "<br>";
echo "Email: " . $info['Email'] . "<br>";
echo "<img src = '" . $info['Photo'] ."' />";
this assumes that your photo holds the full name of the photo, like blah.jpg not just blah. and it also assumes that your photo is in the same directory as your script. if these things are not so, then you will have to alter your script to add on the extension and/or path to the img.

Share this post

Link to post
Share on other sites
Thanks for that, I have it working now.

But I do have a quick question , Do you know how to downsize the images or just show it in a Certain Area, When I open it up it uses the entire screen.

Many Thanks

Share this post

Link to post
Share on other sites


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.