Hi all,
I wonder if you guys can help me. I’m creating a module information system which allows a student to view all the compulsory and optional modules that can be studied within a course. Once a module has been created it then can be associated with a course.
In the admin section I have created a page which allows you to create a module, I’m in the process of creating the course page where it allows the admin to create a course and select the modules the course comprises of. I would like the admin to have the ability to select if the module is compulsory or optional.
Here is an interface design for the courses page.
http://www.2shared.com/photo/mw168s7U/Courses_-_Interface.html
At the moment this is what my table structure is (ERD). http://www.2shared.com/photo/KyCPT4gl/ERD_Model.html
In the join table (coursemodule) I have four attributes (ID, courseID, moduleID, iscore). When a new course has been created and modules are selected it sends the ID of the course and module into the join table.
I would like to populate a second checkbox which would appear next to the module which when both check boxes are checked it would send a ‘1’ to the ‘iscore’ attribute and if it is unchecked but the first checkbox is selected it would send ‘0’ to the ‘iscore’ attribute.
I have set the ‘iscore’ field to Boolean but am struggling what piece of code I would need to write in order to send these values in a check box. I wonder if you guys could help. Thanks
Here is the code within the courses page:
//
Course Title | A value is required. |
Course Modules |
<?php
//This block creates a list of modules from the modules table
$category_list = "";
// $iscore = "";
$sql2 = "SELECT * FROM modules";
$result2 = mysql_query($sql2) or die(mysql_error());
$catCount = mysql_num_rows($result2); //count the output amount
//echo 'No of categories: '.$catCount.' '; if($catCount > 0){ while($row2 = mysql_fetch_array($result2)){ $isCore = false; $moduleID = $row2["moduleID"]; $catName = $row2["moduleTitle"]; // $category_list .= ' '.$catName.' '; $category_list .= ' '.$catName.' '; } } else { $product_list = "Unable to create category list"; } echo $category_list; ?>
// Here is the php code in the course_add.php file Uploading...Uploading...
<?php
require_once('../../Connections/module_system.php');
echo ' Uploading course details to the database...';$courseTitle=$_POST[‘courseTitle’];
$result = mysql_query($query); $pid = mysql_insert_id(); //echo pull out course ID from last record inserted to enter into course module table echo ‘ID of last inserted Course is = ‘.$pid.’ //SQL for modulecourses Uploading course module information to the database…’;$cats_upload = “”; foreach($_POST[‘module’] as $cats) { $isCore=$_POST[‘core’]; echo $pid.’ - ‘.$cats.’ - ‘.$isCore.’ |