Whew! Cannot believe I have found a resolution to this yet or something that lays out the appropriate syntax...

I have a PHP page that is linking to another PHP page.

I am passing a named anchor value to the 2nd PHP page, but it doesn't work. I have tried many, many combinations and cannot get it to work...

Anyone provide any guidance or direction where to locate this?

My samples:

echo "<a href=logplain.php?dayname=$dayofweek#dayname>link to today</a>";

The named anchor is dayname, I am passing a value of Monday, etc. and expect the user to be moved to the Monday value.

Have tried many combo's and cannot get to work.

Can I even use anchors within a PHP string?

    what is the code on your second page?

      No code, well no code that is attempting to read a variable. Simply trying to go to the named anchor on the page that is sent by the first page.

        I like to see the html code from the target page...

          okay, code from the page sending the anchor...

          Sorry, trying lots of variables trying to get the URL to work with PHP!

          LINK.PHP

          <?
          
          $dayofweek = date("l");
          
          echo $dayofweek;
          echo "<- value to send to anchor on other page></br>";
          //echo "<a href=logplain.php?dayname=$dayofweek#dayname>link to today</a>";
          echo '<a href=logplain.php?dayname='.$dayofweek.'#dayname>link to today 1 - a href=logplain.php?dayname='.$dayofweek.'#dayname</a></br>';
          
          echo "<a href='logplain.php#" . $dayofweek . "'>Link to today 2 - a href='logplain.php#" . $dayofweek . "'</a></br>";
          
          echo "<a href='logplain.php?dayname=" . $dayofweek . "#" . $dayofweek . "'>Link to today 3 - a href='logplain.php?dayname=" . $dayofweek . "#" . $dayofweek . "'</a></br>";
          
          echo '<a href="logplain.php?dayname=' . $dayofweek . '#' . $dayname . '">link to today</a>';
          ?>
          

          The page I am linking to with the anchors defined correctly (I think!) I need the anchor value to be dynamic as the value is determined from "today"...

          logplain.php

          echo "<TD BGCOLOR=$color ALIGN=CENTER VALIGN=TOP width=20% ROWSPAN=2><FONT FACE=verdana COLOR=#000000 SIZE=2>";
          
          echo "<a dayname=$danum2>" 
          
          

          This generates HTML that utimately creates an anchor tag below with a dynamic value set (via PHP query) in the anchor. Here is how my anchor looks in the HTML of the page I am linking to:

          <a dayname=Thursday></a>

          So what I am trying to establish is the main page (link.php) calling this anchor above correctly to go right to the location where "Thursday" is located.

          Seems rather challenging via a PHP page vs. using a HTML# anchor. Not sure why???

          Thanks!

            This is not correct at all:
            <a dayname=Thursday></a>

            Judging by the link you are using, you should be doing this:
            <a name="dayname"></a>

            I think you should go review your HTML some... you are clearly misunderstanding the HTML anchor element, and thats what is causing you problems...

              So you're telling me that my value of dayname cannot be dynamic?

              Is that correct?

              I already have other form values with "name", so how do I distinguish these apart.

              I think the point is being missed...

                Thank-you, Thank-you, Thank-you!!!

                That did it, something so simple!

                I was assuming since I already had form names with "name" it would get confused, but changed it to name and worked immediately...

                Thanks again!

                  Write a Reply...