I have never messed with html checkboxes and php before and I am a bit stuck.
Here is what I am doing.
I am dynamically creating the html checkboxes from a MySQL table like this
Code: Select all
<?php session_start();
include_once("../includes/connection.php");
$myuser_name = $_SESSION['myuser_name'];
$listModules = mysql_query("SELECT
id,
user_name,
module_name,
module_path
FROM modules_user WHERE user_name = '$myuser_name'")
or die(mysql_error());
if(mysql_affected_rows()==0){
echo 'There is no modules available for you to grant!';
}
echo '<ul>';
while ($line = mysql_fetch_array($listModules))
{
extract($line);
echo '<li><input name="'.$module_name.'" type="checkbox" id="'.$module_name.'" value="'.$module_name.'" /> <strong>'.$module_name.'</strong></li>';
}
echo '</ul>';
?>
All the bixes that have been checked and posted to the next page I need to insert into the MySQL database.
Code: Select all
INSERT INTO modules_company //This is where I am stuck
I looked at
Code: Select all
<?php
foreach ( $_POST as $key => $val )
{$key}: {$val}
?>
Thanks.