I'm struggling trying to create the form for this part of the pset. I have a controller (sell.php) and a template form (sell_form.php).
Sell.php receives submission from sell_form.php, delete user 's stock from portfolio table and update user's cash in users table.
The thing is that I don't know how to create a form where the user can select any of the stocks he has. This is what I wrote, which doesn't work. The idea is to iterate through an array containing every stock the user has and display that option in the form, but I don't understand how I can combine php with html tags select and option.
<form action="sell.php" method="post"> <fieldset> <div class="form-group"> Stock: <select name = "stock"> // stocks is an array passed through render from the controler with the symbol of every stock <?php foreach($stocks as $stock):?> <option value = <?= $stock ?>> </option> </div> <?php endforeach ?> </fieldset> </form>
Any help would be really appreciated.