jonnypixel Posted June 22, 2010 Share Posted June 22, 2010 Hi, ( Thanks for any help in advance ) I am still learning php and if some one could help i would be very grateful, cheers. I have a menu system and it displays on my tabs correctly but when i hover over the Names with Two words ( eg: Brown Bread ) It only shows &cat=Brown ( In my URL ) $link = 'index.php?area=mypage&cat='; $html .= '<li><a href='.$link.''.$menuData['items'][$itemId]['name'].'>' .$menuData['items'][$itemId]['name']; // find childitems recursively $html .= buildMenu($itemId, $menuData); $html .= '</a></li>'; Can any one please help as to how i can keep the full two words showing in my link please? I want it to show &cat=Brown Bread ( In my URL ) I have tried variations of "\" "\" and '\' '\' But it either shows me an error or just adds it to the link URL. Link to comment https://forums.phpfreaks.com/topic/205492-passing-variable-returns-only-first-word/ Share on other sites More sharing options...
kenrbnsn Posted June 22, 2010 Share Posted June 22, 2010 You should always use quotes on attribute values in HTML tags: <a href="xyz.php?x=this is a test">x</a> You can also use urlencode <a href="http://www.example.com/test.php?x=<?php echo urlencode("this is a test");?>">y</a> In you case, do something like: <?php $html = ''; $link = 'index.php?area=mypage&cat='; $html .= '<li><a href="'.$link.''.$menuData['items'][$itemId]['name'].'">' .$menuData['items'][$itemId]['name']; // find childitems recursively $html .= buildMenu($itemId, $menuData); $html .= '</a></li>'; ?> If you had looked at the generated code, you would have seen that the rest of your string was there. Ken Link to comment https://forums.phpfreaks.com/topic/205492-passing-variable-returns-only-first-word/#findComment-1075350 Share on other sites More sharing options...
jonnypixel Posted June 22, 2010 Author Share Posted June 22, 2010 Thankyou, I used the the urlencode and it works now. Thanks for your help there. Link to comment https://forums.phpfreaks.com/topic/205492-passing-variable-returns-only-first-word/#findComment-1075393 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.