0207100 Posted March 8, 2006 Share Posted March 8, 2006 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 https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/ Share on other sites More sharing options...
ToonMariner Posted March 8, 2006 Share Posted March 8, 2006 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>';} Link to comment https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/#findComment-15349 Share on other sites More sharing options...
0207100 Posted March 8, 2006 Author Share Posted March 8, 2006 [!--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_STRINGIm new to php and havent got a lot of experience. Link to comment https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/#findComment-15362 Share on other sites More sharing options...
AV1611 Posted March 8, 2006 Share Posted March 8, 2006 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 https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/#findComment-15366 Share on other sites More sharing options...
0207100 Posted March 8, 2006 Author Share Posted March 8, 2006 [!--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 https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/#findComment-15376 Share on other sites More sharing options...
AV1611 Posted March 8, 2006 Share Posted March 8, 2006 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 ""'secho $item['Description']."<br />\n"; Link to comment https://forums.phpfreaks.com/topic/4422-making-this-url-work-with-vars/#findComment-15379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.