I've been trying to figure out why my php variables aren't working after the declaration of a dropdown. I've narrowed it down to the dropdown after echoing the variable on all the lines leading up to the declaration, and I found that the variable stops echoing straight after the echo "<select id ='fav' name='fav'>";
Why is this happening? and how can it be fixed?
<?php
$fruit= $_POST['fruit'];
echo $fruit;
echo "<table>";
echo $fruit;
echo "<tr>Favourite Fruit:";
echo $fruit;
echo "<select id ='fav' name='fav'>";
echo $fruit; //this doesn't echo
echo "<option value='Banana'>Banana</option>";
echo "<option value='Strawberry'>Strawberry</option>";
echo "<option value='No Preference'>No Preference</option>";
echo "</select>";
?>