Jump to content

Making This URL Work with Vars -


0207100

Recommended Posts


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
Link to comment
Share on other sites

[!--quoteo(post=352807:date=Mar 8 2006, 07:08 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Mar 8 2006, 07:08 AM) [snapback]352807[/snapback][/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.
Link to comment
Share on other sites

You missed a "slash"... This should do it...
[code]
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>';
}
[/code]
Link to comment
Share on other sites

[!--quoteo(post=352824:date=Mar 8 2006, 07:38 AM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Mar 8 2006, 07:38 AM) [snapback]352824[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You missed a "slash"... This should do it...
[code]
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>';
}
[/code]
[/quote]


Hummm still not working and getting the parse error.

I even tried this:
[code]
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>';
}
[/code]
and it also returned the parse error.

A stupid qustion on my behalf - in the original snip the var had a "." after it
[code]
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>';
}
[/code]

Why is a . not used in this example?

[code]
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>';
}
[/code]
Link to comment
Share on other sites

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";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.