Displaying an Image in php via path in MYSQL

This is a discussion on "Displaying an Image in php via path in MYSQL" within the PHP Forum section. This forum, and the thread "Displaying an Image in php via path in MYSQL are both part of the Program Your Website category.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 5th, 2006, 07:38
Junior Member
Join Date: Oct 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Displaying an Image in php via path in MYSQL

I am trying to display some data via php that i have stored in my mysql database,

I seem to have worked the code out for the text that i want displayed but when i enter the info for the photo that is stored in my mysql i just get the web link displayed instead of the actual image.

My Mysql database structure is as follows:

Code: Select all
create table Players ( PlayerID integer not null primary key auto_increment , Forename varchar(50) , Surname varchar(50) not null , DOB date , RegNo tinyint , Photo varchar(255) , Nickname varchar(50) , Comments varchar(255) , Position varchar(50) , GamesPlayed tinyint , GoalsScored tinyint );
My php code is as follows:

Code: Select all
<? $username="root"; $password=""; $database="players"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM players"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<b><center>Database Output</center></b><br><br>"; $i=0; while ($i < $num) { $Forename=mysql_result($result,$i,"Forename"); $Surname=mysql_result($result,$i,"Surname"); $DOB=mysql_result($result,$i,"DOB"); $Nickname=mysql_result($result,$i,"Nickname"); $Photo=mysql_result($result,$i,"Photo"); echo "<b>$Forename$Surname</b><br>Date Of Birth: $DOB<br>Nickname: $Nickname<br>Photo: $Photo<br><br><hr><br>"; $i++; } ?>
the image is stored in the table under the field called Photo, it is stored as a url to the image as follows:

http://uxellaleague.com/images/teams...6/red_tile.jpg

but is displayed as follows

Chimp
Date Of Birth: 1971-04-08
Nickname: Gaffer
Photo: http://uxellaleague.com/images/teams...6/red_tile.jpg
E-mail:
Web:

someone has said that this may help but i have no idea how to get it to work, should i leave the words std url in, for example?

Code: Select all
$out .= "<img src=\".$prow['Std_URL'])."\" width=\"".$iSize['0']."\" height=\"".$iSize['1']."\" border=\"0\" alt=\"Select this for a more detailed image\">";
Please Help

Thanks in advance
Andy
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jul 5th, 2006, 09:43
Reputable Member
Join Date: Feb 2006
Location: London
Age: 26
Posts: 103
Thanks: 0
Thanked 1 Time in 1 Post
Re: Displaying an Image in php via path in MYSQL

Instead of:

Photo: $Photo

you need:

Photo: <img src=\"$Photo\" />

You are printing out $Photo, which is equal to the path of the image. You just need the image tags so that the browser knows to display the image.

Cheers,
Jim.
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

Tags
displaying, image, php, via, path, mysql

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
PHP/MYSQL Displaying records Ydot PHP Forum 6 Jul 23rd, 2007 06:12
Background image not displaying. Xyis Web Page Design 2 Jul 20th, 2007 14:40
Displaying MySQL database tables on a page vandiermen PHP Forum 3 Jun 30th, 2007 21:58
Linked image keeps displaying a border? ricoantinoro Web Page Design 11 Dec 8th, 2006 23:27
Image gallery not displaying enlarged image AdRock PHP Forum 15 Sep 1st, 2006 11:31


All times are GMT. The time now is 16:06.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization 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