i already searched about displaying the data fields, my problem is how to retain the checked item and then set its value as 1. please help. i tried some code but didn't work:
<html>
<form action='' method='post'>
<?php
$database = 'sample';
$table = 'checklist_stud_columns';
$mysql = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('sample', $mysql) or die(mysql_error($mysql)); // selecting db is not not necessary in this case
$query = sprintf("
SELECT
COLUMN_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_SCHEMA = '%s'
AND TABLE_NAME = '%s'
",
mysql_real_escape_string($database),
mysql_real_escape_string($table)
);
$result = mysql_query($query, $mysql) or die(mysql_error($mysql));
while( false!=($row=mysql_fetch_array($result)) ) {
$name = htmlspecialchars($row['COLUMN_NAME']);
printf("<input type=\"checkbox\" name=\"col[]\" value=\"%s\" />%s (%s)<br />\r\n", $name, $name, $type);
}
if(isset($_POST['submit'])) {
$checked = ($name==1) ? 'checked="checked"' : '';
$checked = ($type==1) ? 'checked="checked"' : '';
mysql_query("UPDATE checklist_stud_columns SET $name=1") or trigger_error(mysql_error(),E_USER_ERROR);
printf("<input type=\"checkbox\" name=\"col[]\" value=\"%s\" />%s (%s)<br />\r\n", $name, $name, $type);
}
?>
<tr><td colspan="2"><input type="submit" name="submit" value="Update Privileges" /></td></tr>
</form>
</html>