Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I found a simple code to pass the values of each checkbox and pass their values onto the next page. Now that the checked values are passed to the next page, how do I write these new checkbox values into the table for each returned value?
Here is the code that prints the form and checkbox and also passes it on to the next page:Code: Select all
<form name='form1' method='post' action='editsubscriber3.php'>
<?
dbConnect();
// This gets all of the reports so that the admin can set permissions for individual reports
$sql = "SELECT * FROM emt_report ORDER BY date_year DESC, date_month DESC, company ASC";
$result = mysql_query($sql) or user_error("mysql error " . mysql_error());
$rank = 1;
while($row = mysql_fetch_assoc($result))
{
$id = $row['id'];
print("[b]<input name='$id' type='checkbox' value='$id'>[/b]");
$rank++;
}Code: Select all
foreach ($_POST as $key => $value )
// --- HOW DO I PRINT AN SQL STATEMENT HERE TO WRITE A NEW ROW FOR EACH RETURNED CHECKBOX VALUE? ---
echo "$key <br>";How do I write the checkbox values into the database? Do I use an array to write an SQL statement for each result? Suggestions? I know it needs to look something like this, but executed each time there is a returned value:
$sql = "INSERT into user_reports VALUES ('$user' , '$key')";
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]