Submitting a PHP form
Posted: Wed Nov 30, 2011 11:08 am
I'm trying to write a form which displays the results of a PHP query (which has queried a table on a Postgre SQL database) in a table, along with a checkbox next to each of the table entries. The user should be able to 'check' the checkboxes for some of the entries, and then click a 'submit' button, which will take them to a 'shopping basket' page, displaying only the items which they had selected from the previous page, by checking the checkboxes (i.e. only the items they have added to the shopping basket).
I currently have the PHP query results displayed in a table, along with a checkbox for each of the entries, but for some reason, the submit button that is part of the form isn't displayed when I view the page in a browser, so I can't click it to check that it works.
The code for my form is below:
What I see when I view the page in a browser, is just the table that is printed out from within the form. Any suggestions?
I currently have the PHP query results displayed in a table, along with a checkbox for each of the entries, but for some reason, the submit button that is part of the form isn't displayed when I view the page in a browser, so I can't click it to check that it works.
The code for my form is below:
Code: Select all
<form action="shoppingBasket.php" method="post">
<?php
// print out the data stored in the $gameTitleQueryResult variable in a table
// put the table inside a php form, so that user can add games to shoppingBasket
echo '<div id="Games">';
echo '<table id="Games" border="1">';
while ($a=pg_fetch_row($gameTitlesQueryResult)){
echo '<tr>';
for ($i=0; $i<pg_num_fields($gameTitlesQueryResult); $i++){
echo '<td>'.htmlspecialchars($a[$i], ENT_QUOTES).'</ td>';
}
echo "<td><input type='checkbox' name='selectGame[]' value='{$a['refnumber']}' /></ td>
</ tr>";
}
echo '</table></ div>';
?>
<input type="submit" value="submit"/>
</form>