[SOLVED] image display php code problem

This is a discussion on "[SOLVED] image display php code problem" within the PHP Forum section. This forum, and the thread "[SOLVED] image display php code problem are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 18th, 2007, 18:57
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] image display php code problem

Ok i have a dreamweaver php file called "Display pic.php" and i have succesfully dragged records to display from a mysql database into text boxes on the php file, one of the text boxes is recording the name of the image from the database, i uploaded the image into the images2 folder located in my sites directory to save clogging up teh database. So the image is located in the images2 file & the name of the image goes into the databases with the rest of the records. I need to display the image in the table at the bottom of my php file.

So basically i have records from my mysql database displaying in text fields on my php file, and i would like a code example of how to get the image to display in the table under the text boxes, aswell as just the name of the image.

Below is my database "dblearn", and the code is using the table called employees:

CREATE DATABASE IF NOT EXISTS dblearn;
USE dblearn;

CREATE TABLE employees (name VARCHAR(30), email VARCHAR(30), phone VARCHAR(30), photo VARCHAR(30))


Here is my code:

PHP: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$con 
mysql_connect("localhost","root","longstand")
  or
  die(
'Damn!, the crazy guinea pigs must have started nibbling on my computer cords again. MYSQL reckons <pre>' mysql_error() . '</pre>');

mysql_select_db("dblearn"$con)
  or
  die (
'Feckin hell, if it\'s not the guinea pigs then it\'s the gerbils. I shouldn\'t let rodents near the computer. MYSQL reckons <pre>' mysql_error() . '</pre>');
 

$name 'Mr Andrew Lloyd'

$query "SELECT * FROM employees WHERE name = '$name' LIMIT 1"
$result mysql_query($query)
   or
   die (
'I finally got rid of the rodents now the grasshoppers are having a dig. damn. MYSQL reckons <pre>' mysql_error() . '</pre>');
   

if (!
mysql_num_rows($result))
 die (
'Did you lie to me? You said that was your name but nothing matched it in the result. I feel so dirty');

$details mysql_fetch_array($result);
 
mysql_free_result($result);
mysql_close($con);
 
?>
 
<p>My Name Is</p>
<p>
  <label>
  <input type="text" name="name" id="name"value="<?php echo isset($details['name']) ? $details['name'] : ''?>" />
  </label>
</p>
<p>My Email Address Is</p>
<p>
  <label>
  <input type="text" name="email" id="email"value="<?php echo isset($details['email']) ? $details['email'] : ''?>" /><br />
  </label>
</p>
<p>
  <label></label> 
My Phone Number Is</p>
<p>
  <label>
  <input type="text" name="phone" id="phone"value="<?php echo isset($details['phone']) ? $details['phone'] : ''?>" /><br /> 
  </label>
</p>
<p>My Photo's Called</p>
<p>
  <label>
  <input type="text" name="photo" id="photo" value="<?php echo isset($details['photo']) ? $details['photo'] : ''?>" /><br />
  </label>
</p>
<table width="200" height="196" border="1">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
<p>
  <label></label>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</body>
</html>


Please help!

Cheers.
Reply With Quote

  #2 (permalink)  
Old Oct 18th, 2007, 19:22
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: image display php code problem

Where abouts do you want the image displayed in your code?
Reply With Quote
  #3 (permalink)  
Old Oct 18th, 2007, 19:25
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: image display php code problem

Or you could try

PHP: Select all

<img src="path_to_images_folder/<?php echo isset($details['photo']) ? $details['photo'] : ''?>" alt="" />
What is going on with all this code getting hidden? It is there!!
Reply With Quote
  #4 (permalink)  
Old Oct 18th, 2007, 19:30
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: image display php code problem

Hi Adrock! I would like the image to be displayed in this part of my code, its a small square table:

PHP: Select all

<table width="200" height="196" border="1">
  <
tr>
    <
td>&nbsp;</td>
  </
tr>
</
table
Cheers
Reply With Quote
  #5 (permalink)  
Old Oct 18th, 2007, 19:39
AdRock's Avatar
SuperMember

SuperMember
Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to AdRock
Re: image display php code problem

Did you try that code i posted (it's hidden but it's there)?
Reply With Quote
  #6 (permalink)  
Old Oct 18th, 2007, 20:40
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: image display php code problem

PHP: Select all

<table width="200" height="196" border="1">
  <tr>
    <td><img src="path_to_images_folder/<?php echo isset($details['photo']) ? $details['photo'] : ''?>" alt="" /></td>
  </tr>
</table>
Did it for you
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #7 (permalink)  
Old Oct 19th, 2007, 17:21
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Re: image display php code problem

Hi Alex!! That Code Of Your Looks Right The only problem is even do i have put the path to the images folder in, the image is still not showing up in the table! Any suggestions???

Cheers 4 replying to my post do fella!

Here's the code you written for me:

PHP: Select all

<table width="200" height="196" border="1">  <tr>    <td><img src="C:\webserver\Apache2\htdocs\Learn\images/<?php echo isset($details['photo']) ? $details['photo'] : ''?>" alt="" /></td>  </tr></table>
Cheers
Reply With Quote
  #8 (permalink)  
Old Oct 19th, 2007, 17:28
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 216
Thanks: 0
Thanked 0 Times in 0 Posts
Talking Re: image display php code problem

Sorry Alex i have sorted the code, its now working fine... Cheers
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
<li> problem :: How to make appear list-style-image while choosing display:inline sayamish Web Page Design 2 Oct 21st, 2007 05:19
[SOLVED] display a image record from a database with a set size longstand PHP Forum 8 Oct 19th, 2007 19:18
[SOLVED] display image if javascript not enabled Voodoochilli JavaScript Forum 1 Oct 4th, 2007 13:58
Display Image Problem Matc JavaScript Forum 1 Jun 17th, 2007 23:32
Image Upload/Display Refresh Problem acruz ASP.NET Forum 1 Jun 20th, 2006 14:08


All times are GMT. The time now is 02:01.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43