[SOLVED] updating/modify checkboxes
Posted: Thu Dec 30, 2004 8:08 am
I have two tables.
One with user selected checkbox result.
The other with the entire category.
I need an update page so users can change their checkbox selected.
I have been having a hard time trying to display my user selected checkboxes from my all categories.
My tables
My attempt has been nested if , nested while, nested foreach but results not what I need
Any help appreciated!
feyd | Help us, help you. Please use
One with user selected checkbox result.
The other with the entire category.
I need an update page so users can change their checkbox selected.
I have been having a hard time trying to display my user selected checkboxes from my all categories.
My tables
Code: Select all
CREATE TABLE `tbl_subjectcat` (
`SubjectCatID` int(11) NOT NULL auto_increment,
`Subject` varchar(25) NOT NULL default '',
`Leveltype` varchar(10) NOT NULL default '',
PRIMARY KEY (`SubjectCatID`)
) TYPE=MyISAM COMMENT='store subjects for pri, sec JC and others modified ver 1.1' AUTO_INCREMENT=62 ;
---data for table `tbl_subjectcat`
INSERT INTO `tbl_subjectcat` VALUES (1, 'English', 'LP');
INSERT INTO `tbl_subjectcat` VALUES (2, 'Math', 'LP');
INSERT INTO `tbl_subjectcat` VALUES (3, 'Science', 'LP');
INSERT INTO `tbl_subjectcat` VALUES (4, 'Chinese', 'LP');
INSERT INTO `tbl_subjectcat` VALUES (5, 'Malay', 'LP');
INSERT INTO `tbl_subjectcat` VALUES (6, 'Tamil', 'LP');
----------------
CREATE TABLE `tbl_tsubjectlevel` (
`TSubjectLevelID` int(11) NOT NULL auto_increment,
`SubjectCatID` int(11) NOT NULL default '0',
`LevelType` varchar(11) NOT NULL default '',
`TutorID` int(11) NOT NULL default '0',
PRIMARY KEY (`TSubjectLevelID`),
KEY `TutorID` (`TutorID`)
) TYPE=MyISAM AUTO_INCREMENT=4697 ;
INSERT INTO `tbl_tsubjectlevel` VALUES (2338, 1, 'LP', 235);
INSERT INTO `tbl_tsubjectlevel` VALUES (2339, 2, 'LP', 235);
INSERT INTO `tbl_tsubjectlevel` VALUES (2340, 3, 'LP', 235);
INSERT INTO `tbl_tsubjectlevel` VALUES (2341, 5, 'LP', 235);Code: Select all
$result = mysql_query("SELECT SubjectCatID, Subject, LevelType FROM tbl_subjectcat WHERE LevelType="LP" ");
$result_LP_selected= mysql_query("SELECT SubjectCatID, LevelType FROM tbl_tsubjectlevel WHERE LevelType="LP" AND TutorID=" .$TutorID." ");
/*
while($myrowSubject=mysql_fetch_row($result))
{
while($myrowT_Subject=mysql_fetch_row ($result_LP_selected))
{
if ($myrowT_Subject[0]==$myrowSubject[0])
{
printf(" <input type="checkbox" value="$myrowSubject[0]" name="$myrowSubject[2][]" checked>$myrowSubject[1]<br>");
break;
}else{
if ($myrowT_Subject[0]!=$myrowSubject[0])
{
printf(" <input type="checkbox" value="$myrowSubject[0]" name="$myrowSubject[2][]">$myrowSubject[1]<br>");
}
}//end while
}*/feyd | Help us, help you. Please use
Code: Select all
andCode: Select all
tags where approriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]