I am a php/mysql newbie and have searched high and low for this answer all morning with no luck.
On my site of movie reviews I want to set up my database to display:
moviename
ratings (graphic)
buy dvd (link)
2 Questions.
1. How do I set up the col/row to pull the appropiate star rating from the images directory?
2. How is it possible to have linked files dispaly from the database? When I put it in now, it comes up as text.
Thanks in advance!
Nay
how to call an image from database
Moderator: General Moderators
-
Paddy
- Forum Contributor
- Posts: 244
- Joined: Wed Jun 11, 2003 8:16 pm
- Location: Hobart, Tas, Aussie
- Contact:
Ok, I will answer question 1. Assume the table is named movies. Just put the image name of the rating in the ratings field and place the actual image in a folder named images. Then do code as follows. (I left out the connection functions.
Could you perhaps reword Q2? I am not sure what you are asking.
Code: Select all
<?php
$result = mysql_query("select * from movies") or exit();
$row = mysql_fetch_row($result);
?>
<img src="images/<?php echo($row[1]); ?>">- mrvanjohnson
- Forum Contributor
- Posts: 137
- Joined: Wed May 28, 2003 11:38 am
- Location: San Diego, CA
In Q2 are you referring to URl?
So you do a
and you get
You need to do this
to make the link "active" http://www.sample.com
So you do a
Code: Select all
<?php
echo $row['url'] ;
?>Code: Select all
www.sample.comCode: Select all
<?php
echo "<a href="".$row['url']."">".$row['url']."</a>" ;
?>-
Cruzado_Mainfrm
- Forum Contributor
- Posts: 346
- Joined: Sun Jun 15, 2003 11:22 pm
- Location: Miami, FL
the best way is
Code: Select all
<?php
$i=0;
$result = @mysql_query("SELECT imagedata FROM images WHERE id = '$i'");
$img = mysql_result($result,0,'imagedata');
header('Content-type: image/jpeg');
echo $img;
?>