joshuamichaelsanders wrote:OK, that is worded very poorly. I have a page, ensemble.php, that should start with a form with a list of ensembles. Once a user picks a particular ensemble, I would like to have the form call ensemble.php with the ensemble name and then produce a roster based on that variable. I just can't seem to get it right. I would think it would be something like this.
$ensemble_code=$_POST['ensemble'];
if ($ensemble_code == '0') {;
echo $varname;
echo "<form action='ensemble.php' method='post'>";
echo "Which Ensemble?";
echo "<select name='ensemble'>";
echo "<option value='1'>Ensemble 1</option>";
echo "<option value='2'>Ensemble 2</option>";
echo "<input type='submit' value='submit'>";
echo "</select>";
echo "</form>";}
else
build table from SQL query
Is this correct?
Well, you're sort of on the right track, although you have some errors there, and you haven't gotten to the part that will do the work. First, your code tests whether $ensemble_code equals zero, but it can
never equal zero, because the only two values it can ever have would be "1" or "2". Your test should be on whether $ensemble_code has been
set or not. So your test should be:
followed by the display of your form. You have a semicolon following the opening curly bracket, which should not be there. Then, what did you have in mind about echoing $varname? Finally, in the else block is where nearly everything happens; you will have a value of either "1" or "2" stored in $ensemble_code, so you will use that to form your query, after connecting to your database, then, as you indicated, build your html table in the while loop that fetches the rows from the database table.