link on other field name

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
sirTemplar
Forum Commoner
Posts: 65
Joined: Wed Dec 18, 2002 1:57 am

link on other field name

Post by sirTemplar »

when i print data from my database, it prints NAME, ADD, etc. the if there is an email and web it print it too. the code looks like this for the if:

Code: Select all

if (isset($row["Web"]) && strcasecmp($row["Web"],"")) 
{
    echo "<tr><td width=425>
    <font size=2 color=#000000>";
 
if (strpos($row['Web']," ") !== FALSE) 
    {
  $Web = explode(" ",$row['Web']);
  foreach ($Web as $Web) 
    
 echo "<a target=_blank href='{$Web}'>{$Web}</a> &nbsp;";
  }
 
else 
    {
  echo "<a target=_blank href='{$row['Web']}'>{$row['Web']}</a></td></tr>";
so it's printing a new line on the output. what i want is instead of a new line, the NAME field becomes a clickable link to of the site. am i making sense? is it possible? some help please.
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: link on other field name

Post by WebbieDave »

sirTemplar wrote:the NAME field becomes a clickable link to of the site
Like the way the WEB field becomes a link?
sirTemplar
Forum Commoner
Posts: 65
Joined: Wed Dec 18, 2002 1:57 am

Re: link on other field name

Post by sirTemplar »

yes. now the output prints it something like:

myname
adress etc.
http://www.somesite.com

what i want is that when there is a web address. it prints:

myname <--- this becomes clickable and linked to http://www.somesite.com
adress etc.
WebbieDave
Forum Contributor
Posts: 213
Joined: Sun Jul 15, 2007 7:07 am

Re: link on other field name

Post by WebbieDave »

On lines 11 and 16, you can replace the second instance of $Web or $row['Web'], with $row['Name'] (or whatever your name variable is called).
sirTemplar
Forum Commoner
Posts: 65
Joined: Wed Dec 18, 2002 1:57 am

Re: link on other field name

Post by sirTemplar »

thank you
Post Reply