I'm trying to pass an URL parameter in an IF and ELSE statement. This is how the initial code looks like with just the link and without the parameter:
<?php
if ($row_checklist_finding_final['item_class'] == "Major")
{
echo '<a href="UserNCR.php">Go to NCR</a>';
}
else
{
echo '<a href="UserOFI.php">Go to OFI</a>';
}
?>
Usually when I'm trying to pass an URL parameter I use this code (this is without if and else statement:
<a href="UserNCR.php?item_id=<?php echo $row_checklist_finding_final['item_id']; ?>">
Go to NCR
</a>
So what I did is, I use my usual way of putting the parameter in the link like this.
The parameter name is item_id
which is equal to value $row_checklist_finding_final['item_id']
<?php
if ($row_checklist_finding_final['item_class'] == "Major")
{
<a href="UserNCR.php?item_id=<?php echo $row_checklist_finding_final['item_id']; ?>">Go to NCR</a>
}
else
{
'<a href="UserOFI.php">Go to OFI</a>';
}
?>
I also tried removing the redundant <?php ?>
like this:
<?php
if ($row_checklist_finding_final['item_class'] == "Major")
{
<a href="UserNCR.php?item_id= echo $row_checklist_finding_final['item_id'];">Go to NCR</a>
}
else
{
'<a href="UserOFI.php">Go to OFI</a>';
}
?>
But there are still error. Did I use the wrong syntax? What should I do to pass the URL parameter in an IF and ELSE statement?