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