11Tami Posted October 20, 2007 Share Posted October 20, 2007 Hello, I need text link number 2 to appear but only if text link 1 has been clicked on. Trouble I'm having is it shows both of them at the same time. So~ <?php $1 = "< href='http://www.website.com/pagelinksareon.php'>link 1</a>"; echo "$1"; if ($1) {echo "< href='http://www.website.com/leadstoapageelsewhere'>link 2</a>";} ?> Shows both at the same time which isn't what I need. Do I need some sort of if $1 is active type command? If so how is that done? How does php know if a link has been clicked on? Please let me know, thank you very much. Quote Link to comment Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 To do this in php you will need to reload the page when they click link 1 because php is interpreted on the server and not the users browser. So: <?php echo '<a href="?id=1">link 1</a>'; if(isset($_GET['id'])) { echo '<a href="http://www.website.com/leadstoapageelsewhere">link 2</a>'; } ?> For something like this your probably better of using javascript though because then you can do it without reloading the page. Quote Link to comment Share on other sites More sharing options...
11Tami Posted October 20, 2007 Author Share Posted October 20, 2007 Thank you very much something like that is just what I need. Refreshing is no problem either and the search engines can also search the links. How do I do it so it can continue? Because there will be other links with different id numbers as well. That way when they click on a different header, different links can appear instead. <?php echo "<a href='?id=1'>category1</a>"; if(isset($_GET['id'])) { echo "<a href='http://www.website.com/leadstoapageelsewhere'>link 1</a>";} echo "<a href='?id=2'>category2</a>"; if(isset($_GET['????'])) { echo "<a href='http://www.website.com/leadstoapageelsewhere'>link 2</a>";} ?> Please let me know, thanks. Quote Link to comment Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 <?php if($_GET['id'] == 1) { //display this link } elseif($_GET['id'] == 2) { //display this link } ?> Quote Link to comment Share on other sites More sharing options...
11Tami Posted October 20, 2007 Author Share Posted October 20, 2007 Thanks a lot, that was it, I'll send you something! Quote Link to comment Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 No need to send me anything. Just mark the topic as solved! Quote Link to comment Share on other sites More sharing options...
steve448 Posted October 20, 2007 Share Posted October 20, 2007 Thats great, so the thanks I get for helping you is SPAM in my message box. Must help you again sometime! Quote Link to comment Share on other sites More sharing options...
11Tami Posted October 21, 2007 Author Share Posted October 21, 2007 Lol, did you take a good look, its not spam but tons of value took me years to find. Gosh something really wrong. Its not working in Mozilla and Opera, need some help to figure out why. Works fine in IE. When you click on the ones that are link it doesn't go to the web pages, it just sits there. <?php echo "<a href='?id=1'>Heading 1</a>"; if ($_GET['id'] == 1){echo "<a href='topageone'>link1</a>";} echo "<a href='?id=2'>Heading 2</a>"; if ($_GET['id'] == 2) {echo "<a href='topage2'>link2</a>";?> I'm calling it with a php include. Maybe my include is incorrect for a full path file. This is how it looks. <?php include 'http://www.website.com/directory1/menu.php'; ?> Can anyone see why the linking code above doesn't work in Mozilla and Opera? Please let me know, thank you very much. Quote Link to comment Share on other sites More sharing options...
11Tami Posted October 22, 2007 Author Share Posted October 22, 2007 I really need some help. I fixed the just above problem but don't know how to fix this. The only problem I have left with this is when there are 2 or more links returned per id, like in example given in id 2.... is sometimes they both are returned and sometimes they aren't. Any way to fix this? <?php echo "<a href='?id=1'>Heading 1</a>"; if ($_GET['id'] == 1){echo "<a href='topageone'>link1</a>";} echo "<a href='?id=2'>Heading 2</a>"; if ($_GET['id'] == 2){echo "<a href='topage2'>link2</a><a href='topage2'>link3</a>";} ?> Please let me know, thank you. Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted October 22, 2007 Share Posted October 22, 2007 try this: <?php // The links that will be shown.. blank for now $links = ""; // Check the $_GET variable to see what we need to show // The $links .= means that the value will ADD TO what $links already is $links .= "<a href='?id=1'>Heading 1</a><br />"; if ($_GET['id'] == 1) { $links .= "<a href='topageone'>link1</a><br />"; $links .= "<a href='topageone'>link2</a><br />"; } $links .= "<a href='?id=2'>Heading 2</a><br />"; if ($_GET['id'] == 2) { $links .= "<a href='topageone'>link1</a><br />"; $links .= "<a href='topageone'>link2</a><br />"; $links .= "<a href='topageone'>link3</a><br />"; $links .= "<a href='topageone'>link4</a><br />"; } // Show links echo $links; ?> Quote Link to comment Share on other sites More sharing options...
11Tami Posted October 23, 2007 Author Share Posted October 23, 2007 I think thats going to do it, I'm pretty sure the search engines will like it and its working much better. Thanks a lot! Quote Link to comment 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.