Jump to content

How to make this link work?


11Tami

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
?>

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.