href passing values to php script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fredb
    New Member
    • Feb 2007
    • 10

    href passing values to php script

    I am trying to create a hyperlink that also passes a value to the destination php
    page? I think the syntax is correct. The value contained in the $id_num variable does not appear in the called PHP script. Below is a sample of the code.

    Thanks for your help.
    Fred

    Code from calling PHP script
    [php]
    <table width="700" border="0" align="center">
    <tr>
    <td width="30%" nowrap><A class=blue href="http://cc010.admin.esu .edu:12345/test/idnumtest.php?i d_num=$idnum&am p;"><?php echo "<font style='font-family: ariel; font-size: 16px;'>" . $fn . ' ' . $mn . ' ' . $ln . "</font>" ?></a></td>
    </tr>
    </table>[/php]

    Code from php script
    [php]
    <?php

    // GET $id_num from Enter_Faculty_I nfo script
    $id_num = $_GET['id_num'];
    print "\n id_num = $idnum\n\n";
    ?>[/php]
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Since the following statement is not generated by PHP but just plain HTML, you must enclose any PHP variable that you want to pass on within the php tags, just like you do with the echo of the style. So you must <?php echo $idnum; ?> it.

    [php]<td width="30%" nowrap><A class=blue href="http://cc010.admin.esu .edu:12345/test/idnumtest.php?i d_num=$idnum&am p;"><?php echo "<font style='font-family: ariel; font-size: 16px;'>" . $fn . ' ' . $mn . ' ' . $ln . "</font>" ?></a></td>[/php]

    Ronald :cool:

    Comment

    • fredb
      New Member
      • Feb 2007
      • 10

      #3
      Originally posted by ronverdonk
      Since the following statement is not generated by PHP but just plain HTML, you must enclose any PHP variable that you want to pass on within the php tags, just like you do with the echo of the style. So you must <?php echo $idnum; ?> it.

      [php]<td width="30%" nowrap><A class=blue href="http://cc010.admin.esu .edu:12345/test/idnumtest.php?i d_num=$idnum&am p;"><?php echo "<font style='font-family: ariel; font-size: 16px;'>" . $fn . ' ' . $mn . ' ' . $ln . "</font>" ?></a></td>[/php]

      Ronald :cool:
      Thank you for your reply. I did as you suggested and modified how I am referencing $idnum:

      <td width="30%" nowrap><A class=blue href="http://cc010.admin.esu .edu:12345/test/idnumtest.php?i d_num=<?php echo $idnum; ?>"><?php echo "<font style='font-family: ariel; font-size: 16px;'>" . $fn . ' ' . $mn . ' ' . $ln . "</font>" ?></a></td>

      The problem is now resolved. Thank you very much for your help.

      Fred

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        You are welcome any time.

        Ronald :cool:

        Comment

        Working...