j05hr Posted November 6, 2009 Share Posted November 6, 2009 How can I make this function that once you click the link in the code it takes you to a new page without html but so the menu_name and content load in it. function public_navigation($sel_subject = null, $sel_page = null) { $subject_set = get_all_subjects(); // 5. Use returned data while ($subject = mysql_fetch_array($subject_set)) { echo "<div class=\"menu-name\">"; echo "<a href=\"buying.php?page=" . urlencode($subject["id"]) . "\">{$subject["menu_name"]}</a>"; echo"</div>"; echo "<div class=\"buying-text\">"; echo "{$subject["content"]}"; echo"</div>"; echo "<div class=\"image\">"; echo"</div>"; } } Thanks, Josh Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/ Share on other sites More sharing options...
JJ2K Posted November 6, 2009 Share Posted November 6, 2009 Either change the link so it contains the variables in the URL for you to get on the new page etc: link.php?variablename1=value1&variablename2=value2 Or change the link to a form submission and send the data that way. Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952237 Share on other sites More sharing options...
j05hr Posted November 6, 2009 Author Share Posted November 6, 2009 How would I put a variable in the name, I would be able to do that but after the link it gets the id of the page so how would I fit a variable into this? "<a href=\"buying.php?page=" . urlencode($subject["id"]) . Thanks Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952239 Share on other sites More sharing options...
JJ2K Posted November 6, 2009 Share Posted November 6, 2009 Not too sure what you mean, what's wrong with what you are doing currently? href=\"buying.php?page=" . urlencode($subject["id"]) ."\" Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952244 Share on other sites More sharing options...
mikesta707 Posted November 6, 2009 Share Posted November 6, 2009 you can append more variables to the url with the & symbol. IE index.php?id=5&othervar=othervalue Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952246 Share on other sites More sharing options...
j05hr Posted November 6, 2009 Author Share Posted November 6, 2009 Sorry didn't really explain it very well, In the picture, this is what should display. In this picture, once you've clicked the link, I want it to display only Home 1 Content, This is the House 1 content..... Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952249 Share on other sites More sharing options...
JJ2K Posted November 6, 2009 Share Posted November 6, 2009 Yea well can't you just do if($_GET['variablename']){ //Display The House Content } else( //Display the List of Houses } Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952254 Share on other sites More sharing options...
j05hr Posted November 6, 2009 Author Share Posted November 6, 2009 Do you mean remove the other code and use this instead or add this in somewhere? Also is the bracket after the else meant to be a curly brace? Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952257 Share on other sites More sharing options...
JJ2K Posted November 6, 2009 Share Posted November 6, 2009 Do you mean remove the other code and use this instead or add this in somewhere? Also is the bracket after the else meant to be a curly brace? Yes you are correct it was meant to be a curly brace. What my code is saying is, if there is a paramter in the URL the only display this data for the house in the URL, else there are no paramters in the URL so display the default list of all houses. Quote Link to comment https://forums.phpfreaks.com/topic/180499-function/#findComment-952478 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.