Hi, my site allows users (buyers) to buy e-learning courses for other users (friends). The buyer completes a form along with choosing an e-learning course for their friend.
The one problem i have is that there are 8 different courses to choose from and some of them have additional settings. Because all of the courses are not the same (some have additional settings) i started off by creating a separate database table for each course type “course_type_1” etc along with the overall “course” table which holds all the main information about the course.
Now, i have realised that the only difference between each of the course types is that some courses have 1 or 2 additional fields SO i am now thinking that i can just add the following columns (in red) to the the overall “course” table and then delete the individual tables that i have created for each course type, so the “course” table would now look like the following:
COURSE (table)
id
buyer_id
friend_id
course_duration
course_type
additional_answer_one
additional_answer_two
I was then hoping to create a course_types.php file that would hold all of the set information for each course type and also determine if the form needs to show the additional text boxes for the additional settings. The course_types.php file would look something like the following:
----------- PLEASE SEE ATTACHED SCREENSHOT FOR A BETTER UNDERSTANDING
// declare courses and there variables
function course_type_1 ()
{
$course_name = Course One Name // this is what shows in the drop down menu
$additional_question_1 = What Is The Name Of The Book
$additional_answer_1 = $book_name
$additional_question_2 = What Is The Authors Gender
$additional_answer_2 = $author_gender
$background_img = canvas.png
$main_img = pencil.png
}
function course_type_2 ()
{
$course_name = Course Two Name // this is what shows in the drop down menu
$additional_question_1 = Please Choose A Color
$additional_answer_1 = $color
$additional_question_2 = NOT REQUIRED
$additional_answer_2 = NOT REQUIRED
$background_img = canvas.png
$main_img = pencil.png
}
etc
1 - what do you think of my new set up
2 - considering i have all of the course types listed in course_types.php - is this the best way for the form to call the Course Types into the drop down
Thanks in advance for your help, i am really looking forward to hearing your reviews on this, thanks…