I have 2 pages sell.php and sell_form.php . When a user selects a stock symbol from the drop-down menu in sell_form.php i have a query in sell.php that is supposed to delete that stock symbol from the database, but what i am getting right now is just a blank page when i click on Sell button. I am not sure i fully understand how the value from the drop-down menu is passed to the sell.php form. This is the code i have so far
this is my sell.php file
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// delete the stock from their portfolio
query("DELETE FROM shares WHERE id = ? AND symbol = ?", $_SESSION["id"],$_POST["symbol"]);
redirect("/");
}
else
{
$rows = query("SELECT * FROM shares WHERE id = ?", $_SESSION["id"]);
//create array to store the shares
$shares = [];
//for each of the user info
foreach($rows as $row){
//lookup stock info
$stock = lookup($row["symbol"]);
if($stock !== false){
$shares[] = [
"name" => $stock["name"],
"price" => $stock["price"],
"shares" => $row["shares"],
"symbol" => $row["symbol"],
"total" => $row["shares"]*$stock["price"]
];
}
}
// render portfolio
render("sell_form.php", ["shares" => $shares, "title" => "Sell"] );
}
this is my sell_form.php
<form action="sell.php" method="post">
<fieldset>
<div class="control-group">
<select name="symbol">
<option value="blank"></option>
<?php foreach ($shares as $symbol):?>
<option value="symbol"><?= $symbol["symbol"]?></option>
<? endforeach ?>
</select>
</div>
<div class="control-group">
<button type="submit" class="btn">Sell all shares</button>
</div>
</fieldset>
</form>