PHP Hyperlink in an if else php statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mark Ruth
    New Member
    • Dec 2011
    • 2

    PHP Hyperlink in an if else php statement

    This code runs fine and creates a link for each record in my record set with Name-=”Open” I hard coded the link to point to record 7 but I need to be able to dynamically grab the actual record number. If Name <>”Open” then the cell says “In Progress” without a link.

    <td>
    <?php
    $v1 = $row_Recordset1['Name'];
    ?>

    <?php
    if ($v1 =="Open")
    {
    echo ('<a href="VacationS ignUp.php?Vacat ionID=7">Signup </a>');
    }
    else
    {
    echo "In Progress";
    }
    ?>
    </td>

    Below, I am trying to get it to work where I replace the 7 in the above code with a php call to get the current record number. I want to make a php call to get the record number of the current record in the repeat area. I can’t seem to get the syntax correct when I have a php call inside my php if…else statement the Hyperlink works fine if I test it in the field as a standalone entry. The problem line is highlighted below.
    I get a blank page when I run this version. Any help on how to fix this would help me keep some of my hair(-:

    <td>
    <?php
    $v1 = $row_Recordset1['Name'];
    ?>

    <?php
    if ($v1 =="Open")
    {
    echo ('<a href="VacationS ignUp.php?Vacat ionID=<?php echo $row_Recordset1['VacationID']; ?>">Signup</a>');
    }
    else
    {
    echo "In Progress";
    }
    ?>
    </td>
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You're already in a PHP code block. There's no need to start another one. Also, you don't need to echo it.
    Code:
    echo ("<a href=\"VacationSignUp.php?VacationID=$row_Recordset1['VacationID']\">Signup</a>");

    Comment

    • Mark Ruth
      New Member
      • Dec 2011
      • 2

      #3
      I tried your code and still got an empty page but your syntax example send me down a path that resulted in me finding a working solution.
      here is my working section of code:
      Code:
      <?php 
      $v1 = $row_Recordset1['Name'];
      $v2 = $row_Recordset1['VacationID'];
      if ($v1 =="Open")
      {
      echo ("<a href=\"VacationSignUp.php?VacationID=$v2\">Signup</a>");
      }
      else
      {
      echo "In Progress";
      }
      ?>
      Thanks for the help.

      Comment

      Working...