Page 1 of 1

link on other field name

Posted: Tue Jul 29, 2008 1:28 am
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.

Re: link on other field name

Posted: Tue Jul 29, 2008 1:52 am
by WebbieDave
sirTemplar wrote:the NAME field becomes a clickable link to of the site
Like the way the WEB field becomes a link?

Re: link on other field name

Posted: Tue Jul 29, 2008 1:59 am
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.

Re: link on other field name

Posted: Tue Jul 29, 2008 2:04 am
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).

Re: link on other field name

Posted: Tue Jul 29, 2008 5:56 am
by sirTemplar
thank you