iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old October 18th, 2007, 02:57 PM   #1
Reputable Member
 

Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 longstand is on a distinguished road
[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:

Code:
<!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.
longstand is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 18th, 2007, 03:22 PM   #2
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
Re: image display php code problem

Where abouts do you want the image displayed in your code?
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 18th, 2007, 03:25 PM   #3
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
Re: image display php code problem

Or you could try

Code:
<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!!
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 18th, 2007, 03:30 PM   #4
Reputable Member
 

Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 longstand is on a distinguished road
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:

Code:
<table width="200" height="196" border="1">
  <
tr>
    <
td>&nbsp;</td>
  </
tr>
</
table
Cheers
longstand is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 18th, 2007, 03:39 PM   #5
Highly Reputable Member
 

Join Date: Jul 2006
Location: Devon, England
Posts: 565
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 AdRock will become famous soon enough
Re: image display php code problem

Did you try that code i posted (it's hidden but it's there)?
AdRock is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 18th, 2007, 04:40 PM   #6
Elite Veteran
 

Join Date: Jul 2007
Location: Webforumz 24/7
Age: 16
Posts: 3,802
Blog Entries: 9
Thanks: 2
Thanked 3 Times in 3 Posts
Rep Altering Power: 0 alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all alexgeek is a name known to all
Re: image display php code problem

Code:
<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
__________________
Web Design and Development Blog

Alex Perry
Technical Administrator.
alexgeek is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 19th, 2007, 01:21 PM   #7
Reputable Member
 

Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 longstand is on a distinguished road
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:

Code:
<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
longstand is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old October 19th, 2007, 01:28 PM   #8
Reputable Member
 

Join Date: Oct 2007
Location: Liverpool UK
Age: 30
Posts: 247
Thanks: 1
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 longstand is on a distinguished road
Talking Re: image display php code problem

Sorry Alex i have sorted the code, its now working fine... Cheers
longstand is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 HTML, XHTML and CSS 2 October 21st, 2007 01:19 AM
[SOLVED] display a image record from a database with a set size longstand PHP 8 October 19th, 2007 03:18 PM
[SOLVED] display image if javascript not enabled Voodoochilli JavaScript 1 October 4th, 2007 09:58 AM
Display Image Problem Matc JavaScript 1 June 17th, 2007 07:32 PM
Image Upload/Display Refresh Problem acruz .NET 1 June 20th, 2006 10:08 AM


Search Engine Optimization by vBSEO 3.2.0 RC8