hyperlink from DB

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
amao
Forum Newbie
Posts: 21
Joined: Sun May 10, 2009 5:13 am

hyperlink from DB

Post by amao »

Hi all
I have this statement
$query4="SELECT flink,reals FROM tb_links ORDER BY id DESC LIMIT 1 ";

I need to make the href=flink and hyperlink real like
<a href=Flink>reals</a>
please help
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: hyperlink from DB

Post by jaoudestudios »

Once you have the flink variable in the array returned from the database.

Just use...

Code: Select all

<?php echo '<a href="'.$r['flink'].'">Link</a>'; ?>
 
amao
Forum Newbie
Posts: 21
Joined: Sun May 10, 2009 5:13 am

Re: hyperlink from DB

Post by amao »

jaoudestudios wrote:Once you have the flink variable in the array returned from the database.

Just use...

Code: Select all

<?php echo '<a href="'.$r['flink'].'">Link</a>'; ?>
 
thanks jaoudestudios
it just take the first letter not the whole FLINK value
$data=mysql_result($result,0);
<?php echo '<a href="'.$data['flink'].'">Link</a>'; ?>
mattpointblank
Forum Contributor
Posts: 304
Joined: Tue Dec 23, 2008 6:29 am

Re: hyperlink from DB

Post by mattpointblank »

$data = mysql_fetch_array($result);
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: hyperlink from DB

Post by Eric! »

The way your data is stored is different depending on the mysql function. If you use mysql_result

Code: Select all

$data=mysql_result($result,0,'flink');
$link=mysql_result($result,0,'reals');
<?php echo '<a href="'.$data.'">'.$link.'</a>'; ?>
The faster (for more data) and more popular mysql_fetch_array

Code: Select all

$data = mysql_fetch_array($result);
<?php echo '<a href="'.$data['flink'].'">'.$data['reals'].'</a>'; ?>
 
amao
Forum Newbie
Posts: 21
Joined: Sun May 10, 2009 5:13 am

Re: hyperlink from DB

Post by amao »

Eric! wrote:The way your data is stored is different depending on the mysql function. If you use mysql_result

Code: Select all

$data=mysql_result($result,0,'flink');
$link=mysql_result($result,0,'reals');
<?php echo '<a href="'.$data.'">'.$link.'</a>'; ?>
The faster (for more data) and more popular mysql_fetch_array

Code: Select all

$data = mysql_fetch_array($result);
<?php echo '<a href="'.$data['flink'].'">'.$data['reals'].'</a>'; ?>
 
thanks very much
Post Reply