Create a dynamic hyperlink inside a cell and send variable to another page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mgrichen
    New Member
    • Feb 2013
    • 8

    #1

    Create a dynamic hyperlink inside a cell and send variable to another page

    Hi
    I have the following piece aof code

    Code:
           while($row = mysql_fetch_array($event))
            {
              echo "<tr>";
              echo "<td>" . $row['surnameNM'] . "</td>";
              $str_id = $row['personID'];
              echo "<td>" . $row['nameNM'] . "</td>";
    echo "<td>" . $row['personID'] . "</td>";
              echo "</tr>";
            }
            mysql_close($getSurname);
    I would like to create an hyperlink for each row on the NameNM field and send the corresponding personID within the hyperlink, something like getPerson.php?I dentity=$str_id .

    I have tried several options and none works. Please keep in mind it must be inside the "<td>" cell.

    Thank you in advance
    Last edited by Rabbit; Feb 14 '13, 11:44 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    There's no hyperlink in your code.

    Comment

    • mgrichen
      New Member
      • Feb 2013
      • 8

      #3
      Exactly. I know how to do it in asp but not in PHP. I have tried several options but none works.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You would have to show us one of the options you've tried before I can tell you where you went wrong.

        Comment

        • mgrichen
          New Member
          • Feb 2013
          • 8

          #5
          Here it goes
          <a href="getPerson .php?identity=$ str_id">Link to Page</a>
          How do I place this inside
          echo "<td>" . $row['nameNM'] . "</td>";
          The variable $str_id is the personID of the nameNM I want.

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            You can echo it like it is, you'll just need to escape the double quotes.

            Comment

            • mgrichen
              New Member
              • Feb 2013
              • 8

              #7
              I am a complete newbie on PHP
              Nevertheless i wrote
              echo "<td><a href=getPerson. php?identity=$s tr_id>".$row['nameNM']."</a></td>";
              and it works.
              Thank you for your didactical patience.

              Comment

              Working...