chimp Posted July 5, 2006 Share Posted July 5, 2006 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]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 );[/code]My php code is as follows:[code]<? $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++; } ?>[/code]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_200506/red_tile.jpgbut is displayed as followsChimpDate Of Birth: 1971-04-08Nickname: GafferPhoto: http://uxellaleague.com/images/teams_200506/red_tile.jpgE-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]$out .= "<img src=\".$prow['Std_URL'])."\" width=\"".$iSize['0']."\" height=\"".$iSize['1']."\" border=\"0\" alt=\"Select this for a more detailed image\">";[/code]Please HelpThanks in advanceAndy Quote Link to comment https://forums.phpfreaks.com/topic/13706-displaying-an-image-in-php-via-path-in-mysql/ Share on other sites More sharing options...
indalecio Posted July 5, 2006 Share Posted July 5, 2006 Your trying to get php to do too much for you with too little code. The best solution for this, as I use this in my website, but in a different way is I get the image link stored in the database, then pull the link and put in the <img> tag. Like so:[code]<img src="<? echo $IMAGE_VARIABLE_LINK; ?>">[/code]Don't try to add the image tags to php the way your doing, just manually add them and have php insert the link into the tag. If people don't have a photo you can default to one if that input is empty. Quote Link to comment https://forums.phpfreaks.com/topic/13706-displaying-an-image-in-php-via-path-in-mysql/#findComment-53207 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.