hi all;
I have the following issue:
I need to select specific people in a table which is created through a recordset loop and then email those people details
this is the working of the code:
step 1: Query recordset
step 2: create table with recordset and place an array checkbox in one of the tables columns
I have managed to get here so far, the following steps is what II need assistance with
---------------------------------------
step 3: once the user hits submit the code needs to recall the boxes that have been selected
step 4: mail the people that have been selected via the checkboxes
Any help would be greatly appreciated, as the previous methods I used seemed to be inadequate.
thanks
looping through selected fields in table
Moderator: General Moderators
i usually store all the rows in a session then...
Now i have an array with indices from 0 to n-1 rows...
So i generate a table/list with selectboxes with values from 0 to n-1
And when this page is submitted it's a matter of looking up the selected rows
This mechanism gives you a simple 1 to 1 mapping between rows and select boxes (i do this to avoid problems with primary keys that exist out of more than 1 column)
Code: Select all
session_start();
...
$result = mysql_query(...);
$rows = array();
while ($row = mysql_fetch_assoc($result))
{
$rows[] = $row;
}
...
$_SESSION['rows'] = $rows;So i generate a table/list with selectboxes with values from 0 to n-1
Code: Select all
$i = 0;
foreach($rows as $row)
{
echo "<tr>";
echo "<td class='select'><input type='checkbox' name='select[]' value='$i'/></td>";
// output other columns of the row
echo "</tr>";
}And when this page is submitted it's a matter of looking up the selected rows
Code: Select all
session_start();
...
// loop through all selected rows
foreach($_POST['select'] as $select)
{
$row = $_SESSION['rows'][$select];
}This mechanism gives you a simple 1 to 1 mapping between rows and select boxes (i do this to avoid problems with primary keys that exist out of more than 1 column)