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

Reply
href from database field??
Old 07-13-2010, 01:27 PM href from database field??
Novice Talker

Posts: 6
Name: David Reid
Trades: 0
HI,
I have a table in my database that has two fields, one called imgfile1 and the other called url

I can display the image from the imgfile1 field without a problem but what i want to do is create a hyperlink to another website using the address in the url field.

I am very much a novice at this and any help would be much appreciated

my code is below:

PHP Code:
<?php
$result 
mysql_query("SELECT * FROM banners1") or die(mysql_error());  
while(
$row mysql_fetch_array($result)){
  
$imgfile1_txt=$row['imgfile1'];
  
$url_txt=$row['url'];
 echo 
'<img src="http://www.webmaster-talk.com/images/'.$imgfile1_txt.'" width="161" border="0"vspace="3"></a>';
}
?>

Last edited by chrishirst; 07-13-2010 at 02:06 PM..
chopper3226 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-13-2010, 01:36 PM Re: href from database field??
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The problem is with your html. You have an opening img tag and a closing a tag. If you want an image to function as a link the code is:
HTML Code:
<a href="linkaddress"><img src="imageaddress" /></a>
In order to accomplish this in your code change:
PHP Code:
echo '<img src="images/'.$imgfile1_txt.'" width="161" border="0"vspace="3"></a>'
to
PHP Code:
echo '<a href="' $url_txt '"><img src="images/'.$imgfile1_txt.'" width="161" border="0"vspace="3" /></a>'
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 07-13-2010, 01:43 PM Re: href from database field??
Novice Talker

Posts: 6
Name: David Reid
Trades: 0
Thanks for the quick response and the solution to my problem.
Talkupation added!!
chopper3226 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to href from database field??
 

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.11424 seconds with 12 queries