I am trying to build a HTML form if an item is in stock, but as I’m storing the html in a string variable using single quotes to delimit it, and then setting form attributes using double quotes inside the form, how then can I refer to a php variable inside the form to dynamically assign a value to ‘addItem’. If you look at my code you’ll see what I mean! I will echo the contents of $summary after this has been done, and $summary at this point contains information extracted from my SQL database about the product.
$summary .= '<form id="testbasket" method="GET" target="_parent" action="cattest.php" >
<input type="text" id="addItem" name="addItem" value='.'"<?php echo $plantname; ?>"'.'>
<input type="submit" value="Add To Basket" />
</form>';
Note: I’m using _parent as the target because this sits inside an iframe in the parent page.
Many thanks.
1 Answer