Nesting PHP within PHP
I have an image with some underlying PHP which, when clicked, causes it to link to another page and pass a parameter, this works fine when the image is on it's own in a table cell see www.hollisterairshow.com/admin/admin.php and then select the "Needs with Offers" tab and you'll see the icon on the right which takes the user to a page to update the Offer. The working code is shown below:
<td>
<a href="editoffer.php?offerId=<?php echo $row_rsNeedsOffers['offerId']; ?>">
<img src="../images/edit.png" alt="Edit Offer" width="24" height="24" border="0" align="middle" Title = "Edit Offer"/></a>
</td>
I didn't like the look of the page so I improved it....sigh...and now it doesn't work ! The offending page can be seen here www.hollisterairshow.com/admin/admin2.php and then select the "Needs with Offers" tab and you'll see the icon at the end of each offer. The parameter is not being evaluated and instead of correctly passing for example "http://www.hollisterairshow.com/admin/editoffer.php?offerId=18" it passes "http://www.hollisterairshow.com/admin/editoffer.php?offerId=<?php echo $row_rsNeedsOffers['offerId']; ?>" . As you can see the parameter is not being evaluated and the PHP is being passed as a parameter. I tried removing the <?PHP and ?> and this failed. The relevant code is shown in red below
<?php do { ?>
<p>
<?php
echo "<b>".$row_rsNeedsOffers['title']."("."</b>".$row_rsNeedsOffers['quantityneeded']." needed)"."<br />".$row_rsNeedsOffers['name']."(".$row_rsNeedsOffers['quantityoffered']." available) ".$row_rsNeedsOffers['commentoffered']." E-mail: ".$row_rsNeedsOffers['email']." Phone: ".$row_rsNeedsOffers['phone']." Admin comment: ".$row_rsNeedsOffers['admincomment']." Status: ".$row_rsNeedsOffers['status']." "."<a href=\"editoffer.php?offerId=<?php echo \$row_rsNeedsOffers['offerId']; ?>\"><img src=\"../images/edit.png\" alt=\"Edit Offer\" width=\"16\" height=\"16\" border=\"0\" align=\"middle\" Title = \"Edit Offer\"/></a>";
?>
</p>
<?php } while ($row_rsNeedsOffers = mysql_fetch_assoc($rsNeedsOffers)); ?>
I must have made a syntax error somewhere, but I just don't see it.
Thanks,
Tony
