I currently have some PHP on my website, which is querying a PostgreSQL database table, and displaying the results of the query in a table on the web page.
The database table contains a list of games, along with their price, description and reference number- my PHP query is pulling all of this information from the database database table, and displaying it in a table on my web page- with one game and its info per row. I have also added a checkbox to the end of each row in my PHP.
What I now need to do, is write some JavaScript to loop through the table, checking which checkboxes the user has ticked, and store the game information for each game the user has selected, in a PHP session variable, so that the user can view the items they've selected on the next page (like a shopping basket).
This is the code that's displaying the table with the games, and all of their information, along with a checkbox.
Code: Select all
<?php
// print out the data stored in the $gameTitleQueryResult variable in a table
// put the table inside a 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>';
?>
Thanks in advance!