//Load import data if ($_POST['upload']) { $classImportInfoArray = uploaded_file_data_load(); $classInsertInfoArray = import_data_form($classImportInfoArray); //ADD the COURSE data $CLASS_TABLE_KEY_NAMES_ARRAY = array_picker($classImportInfoArray, 0); //Pick the table key names from import array. $CLASS_TABLE_KEY_NAMES_ARRAY = array_key_insert($CLASS_TABLE_KEY_NAMES_ARRAY, "ID", "ID"); //The imporrt data not include ID key, so add it. $CLASS_TABLE_KEY_TYPES_ARRAY = table_key_types_auto_fill($CLASS_TABLE_KEY_TYPES_ARRAY, $CLASS_TABLE_KEY_NAMES_ARRAY, 0, "varchar(15)", 1); $CLASS_TABLE_KEY_TYPES_ARRAY = array_key_insert($CLASS_TABLE_KEY_TYPES_ARRAY, "ID", "int NOT NULL AUTO_INCREMENT, PRIMARY KEY(ID)"); //COURSE_LEFT TABLE structure create $courseListArrayCount0 = count($courseListArray); for ($i = 0; $i < $courseListArrayCount0; $i++) { $CLASS_TABLE_KEY_NAMES_ARRAY = array_key_insert($CLASS_TABLE_KEY_NAMES_ARRAY, $courseListArray[$i]['COURSE_KEY_NAME'], $courseListArray[$i]['COURSE_KEY_NAME']); $CLASS_TABLE_KEY_TYPES_ARRAY = array_key_insert($CLASS_TABLE_KEY_TYPES_ARRAY, $courseListArray[$i]['COURSE_KEY_NAME'], "varchar(15)"); } database_table_create($CLASS_TABLE_NAME, $CLASS_TABLE_KEY_NAMES_ARRAY, $CLASS_TABLE_KEY_TYPES_ARRAY); $tableKeyNumbersCount = count($classInsertInfoArray); for ($i = 0; $i < $tableKeyNumbersCount; $i++) { //COURSE_LEFT auto fill method $courseListArrayCount0 = count($courseListArray); $classType = $classInsertInfoArray[$i]['CLASS_TYPE']; for ($j = 0; $j < $courseListArrayCount0; $j++) { $classInsertInfoArray[$i][$courseListArray[$j]['COURSE_KEY_NAME']] = $courseListArray[$j][$classType]; } table_data_add($CLASS_TABLE_NAME, $CLASS_TABLE_KEY_NAMES_ARRAY, $classInsertInfoArray[$i]); } } //Reload $CLASS_TABLE_KEY_NAMES_ARRAY. $CLASS_TABLE_KEY_NAMES_ARRAY = table_key_names_array_get($CLASS_TABLE_NAME);
//COURSE_KEY_NAME info add method. $courseInsertInfoArrayCount0 = count($courseInsertInfoArray); for ($i = 0; $i < $courseInsertInfoArrayCount0 - 1; $i++) { //[BUG][120501_1] Import file have a title line, so that "-1". $courseInsertInfoArray[$i]['COURSE_KEY_NAME'] = "COURSE_" . $i; } //ADD the COURSE data $COURSE_TABLE_KEY_NAMES_ARRAY = array_picker($courseImportInfoArray, 0); //Pick the table key names from import array. $COURSE_TABLE_KEY_NAMES_ARRAY = array_key_insert($COURSE_TABLE_KEY_NAMES_ARRAY, "id", "id"); //The import data not include ID key, so add it. $COURSE_TABLE_KEY_NAMES_ARRAY = array_key_insert($COURSE_TABLE_KEY_NAMES_ARRAY, "COURSE_KEY_NAME", "COURSE_KEY_NAME"); //The import data not include COURSE_KEY_NAME key, so add it. $COURSE_TABLE_KEY_TYPES_ARRAY = table_key_types_auto_fill($COURSE_TABLE_KEY_TYPES_ARRAY, $COURSE_TABLE_KEY_NAMES_ARRAY, 0, "varchar(15)", 1); $COURSE_TABLE_KEY_TYPES_ARRAY = array_key_insert($COURSE_TABLE_KEY_TYPES_ARRAY, "id", "int NOT NULL AUTO_INCREMENT, PRIMARY KEY(id)"); $COURSE_TABLE_KEY_TYPES_ARRAY = array_key_insert($COURSE_TABLE_KEY_TYPES_ARRAY, "COURSE_KEY_NAME", "varchar(15)"); database_table_create($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY, $COURSE_TABLE_KEY_TYPES_ARRAY); unset($COURSE_TABLE_KEY_NAMES_ARRAY['id']); //Drop the table key id for data insert by key names array. for ($i = 0; $i < $courseInsertInfoArrayCount0 - 1; $i++) { //Import file have a title line, so that "-1". table_data_add($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY, $courseInsertInfoArray[$i]); } } //Reload $COURSE_TABLE_KEY_NAMES_ARRAY. $COURSE_TABLE_KEY_NAMES_ARRAY = table_key_names_array_get($COURSE_TABLE_NAME); //QUERY the $courseListArray $courseListArray = table_data_query($COURSE_TABLE_NAME, $COURSE_TABLE_KEY_NAMES_ARRAY); //------ -[ Views Functions ]- ------ div_head_output_with_class_option("mainMiddle"); //Print Main Title