Jump to content


Photo

Making This URL Work with Vars -


  • Please log in to reply
5 replies to this topic

#1 0207100

0207100
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 March 2006 - 11:55 AM


I need to take this array and have it print.

function print_link_item($item) {
echo '<p>';
echo $item['Heading']."<br />\n";
echo $item['URI']."<br />\n";
echo $item['Description']."<br />\n";
echo $item['URL'];
echo '</p>';


I want to have the Heading display the Link and when the user mouse overs the link instead of seeing the URI (real url) they will see the [URL] i want them to see.

How do I make the following work, I have fiddled with it and just cant make it work.

<a href="[URI]" target = '_blank' onMouseOver="window.status='[URL]'; return true;" onMouseOut="window.status=''; return true;">[Heading]</a>

Thanks

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 March 2006 - 12:08 PM

function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"'_blank" onMouseOver=\"window.status='$item['URL']'; return true;\" onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>

echo '</p>';
}
follow me on twitter @PHPsycho

#3 0207100

0207100
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 March 2006 - 12:30 PM

[!--quoteo(post=352807:date=Mar 8 2006, 07:08 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Mar 8 2006, 07:08 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"'_blank" onMouseOver=\"window.status='$item['URL']'; return true;\" onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>

echo '</p>';
}
[/quote]


Thanks for the help, I tried your code but have got the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING

Im new to php and havent got a lot of experience.

#4 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 March 2006 - 12:38 PM

You missed a "slash"... This should do it...
function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"_blank\" onMouseOver=\"window.status='$item['URL']'; return true;\" onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>
echo '</p>';
}


#5 0207100

0207100
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 March 2006 - 12:57 PM

[!--quoteo(post=352824:date=Mar 8 2006, 07:38 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 8 2006, 07:38 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You missed a "slash"... This should do it...
function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"_blank\" onMouseOver=\"window.status='$item['URL']'; return true;\" onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>
echo '</p>';
}
[/quote]


Hummm still not working and getting the parse error.

I even tried this:
function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"_blank\" onMouseOver=\"window.status='$item['URL']'; return true;\"onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>";
echo '</p>';
}
and it also returned the parse error.

A stupid qustion on my behalf - in the original snip the var had a "." after it
function print_link_item($item) {
        echo '<p>';
        echo $item['Heading']."<br />\n";
        echo $item['URI']."<br />\n";
        echo $item['Description']."<br />\n";
        echo $item['URL'];
        echo '</p>';
}

Why is a . not used in this example?

function print_link_item($item) {
echo '<p>';
echo "<a href=\"$item['URI']\" target =\"_blank\" onMouseOver=\"window.status='$item['URL']'; return true;\" onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>
echo '</p>';
}


#6 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 March 2006 - 01:10 PM

In the first case, the $item is aready included in the echo " "

echo "<a href=\"$item['URI']\" target =\"_blank\" onMouseOver=\"window.status='$item['URL']'; return true;\"onMouseOut=\"window.status=''; return true;\">$item['Heading']</a>";

In the second case, $item is not required to be in "" but it must be concenated to the portion that does require the ""'s

echo $item['Description']."<br />\n";





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users