Jump to content

Viewing Images


garlicka

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.

Thanks
Link to comment
https://forums.phpfreaks.com/topic/11991-viewing-images/
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:
[code]
$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'] ."' />";
[/code]
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.
Link to comment
https://forums.phpfreaks.com/topic/11991-viewing-images/#findComment-45605
Share on other sites

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.