By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,064 Members | 1,388 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,064 IT Pros & Developers. It's quick & easy.

PHP Hyperlink in an if else php statement

P: 2
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="VacationSignUp.php?VacationID=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="VacationSignUp.php?VacationID=<?php echo $row_Recordset1['VacationID']; ?>">Signup</a>');
}
else
{
echo "In Progress";
}
?>
</td>
Dec 6 '11 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,366
You're already in a PHP code block. There's no need to start another one. Also, you don't need to echo it.
Expand|Select|Wrap|Line Numbers
  1. echo ("<a href=\"VacationSignUp.php?VacationID=$row_Recordset1['VacationID']\">Signup</a>");
Dec 7 '11 #2

P: 2
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:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $v1 = $row_Recordset1['Name'];
  3. $v2 = $row_Recordset1['VacationID'];
  4. if ($v1 =="Open")
  5. {
  6. echo ("<a href=\"VacationSignUp.php?VacationID=$v2\">Signup</a>");
  7. }
  8. else
  9. {
  10. echo "In Progress";
  11. }
  12. ?>
Thanks for the help.
Dec 7 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.