Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
help linking to image files using variables.
Old 07-04-2010, 07:17 PM help linking to image files using variables.
Skilled Talker

Posts: 53
Trades: 0
hey guys

I'm having a little trouble building links to retrieve images using php variables. My server has a folder called "thumbnails" and in the folder I have sub-folders called "hockey" "basketball" "baseball" and "football", each of which hold little jpg images. I have a MySQL database that have fields called "section" and "thumbnail_path", which have a path to a specific image and the section of that image that correlate to that row of data.

Now the thumbnail image appears
when the thumbnail_path field in the db is in the form "thumbnails/hockey/rangers.jpg" and the php code is...
PHP Code:
<?php 
$thumbnail 
$row['thumbnail_path'];
echo 
"<img src='http://www.mysite.com/$thumbnails'></img>" 
?>

But what I'm trying to do is set it up so that the
thumbnail_path field in the db is in the form
"rangers.jpg" and the php code is...
PHP Code:
<?php 
$section 
$row['section'];
$thumbnail $row['thumbnail_path'];
echo 
"<img src='http://www.mysite.com/thumbnails/$section/$thumbnail'></img>" 
?>
I've can't seem to get method #2 to work. any suggestions?

Last edited by worldy; 07-04-2010 at 07:19 PM..
worldy is offline
View Public Profile
 
 
Register now for full access!
Old 07-04-2010, 07:49 PM Re: help linking to image files using variables.
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
But what value do you have stored in the cell "section"?

For example if you have something like this:
HTML Code:
section   |  thumbnail_path
-------------------------
hockey   |  rangers.jpg
It should work.
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
View Public Profile
 
Old 07-04-2010, 08:58 PM Re: help linking to image files using variables.
Skilled Talker

Posts: 53
Trades: 0
yes, Marik, thats exactly how I have the db setup. But it just dosn't work, I have no idea what I'm doing wrong.. heres the full codng if it helps anyone.

PHP Code:
 <?php
$get 
mysql_query("SELECT * FROM videos WHERE section='other' ORDER by id DESC LIMIT $start$per_page");
while(
$row mysql_fetch_assoc($get))
{
$video_title $row['video_title'];
$video_path $row['video_path'];
$length $row['length'];
$section $row['section'];
$date_added $row['date_added'];
$thumbnail $row['thumbnail_path'];
?>
 
<div id = "vidfeed">
<div id = "vidfeedthumb">
<div class="thumbnail"><?php echo "<a href='player.php?v=$section/$video_path'><img src='http://www.mysite.com/thumbnails/$section/$thumbnail' alt='$video_title'></img></a>"?></div>  
</div>
<div id = "vidfeedinfo">
<div class="titlecell"><?php echo "<a href='player.php?v=$section/$video_path'>$video_title</a>"?> </div>
<div class="length"><?php echo "Added: $date_added &nbsp;&nbsp;&nbsp; Category: $section";?> </div>
</div>
</div>
 
<?php
}
?>

Last edited by worldy; 07-04-2010 at 10:51 PM..
worldy is offline
View Public Profile
 
Old 07-05-2010, 12:07 AM Re: help linking to image files using variables.
Marik's Avatar
Skilled Talker

Posts: 99
Trades: 0
From the additional code you provided it looks like your query is only selecting record sets that have the value "other" for the section cell. In the first post you wanted to show a thumbnail that had for it's section value the word "hockey", so my guess is that's why it's not working.

Try this query instead:

HTML Code:
SELECT * FROM videos ORDER by id DESC LIMIT $start, $per_page
__________________

Please login or register to view this content. Registration is FREE
Marik is offline
View Public Profile
 
Old 07-05-2010, 12:08 AM Re: help linking to image files using variables.
Skilled Talker

Posts: 53
Trades: 0
ok nvm, problem resolved. the thumbnails files on the server had a typo in it. im an idiot
worldy is offline
View Public Profile
 
Closed Thread     « Reply to help linking to image files using variables.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61952 seconds with 12 queries