function add_user($userInfo) { if (!(isset($userInfo['username']) && isset($userInfo['email']) && isset($userInfo['password']))) { throw new Exception("Requires username, email, and password"); } $dbh = new PDOConnection(); CheckUsernameEmailExists($dbh, $userInfo); $user_id = AddToUsers($dbh, $userInfo); return array('user_id' => $user_id); }
$inputFileName = $UploadDirectory . $NewFileName; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); // Get worksheet dimensions $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); // Loop through each row of the worksheet in turn for ($row = 1; $row <= $highestRow; $row++) { // Read a row of data into an array $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); foreach ($rowData[0] as $k => $v) { //$resp .= "Row: ".$row."- Col: ".($k+1)." = ".$v."<br />"; $res = AddToUsers($v, "D"); if ($res == "1") { $i = $i + 1; } else { $j = $j + 1; $userDefault .= $v . ", "; } $resp = AddToTable($v, $organ, $course, "Mentee"); if ($resp == "1") { $k = $k + 1; } else { $l = $l + 1; $menteeDefault .= $v . ", "; } } // end of foreach
$inputFileName = $UploadDirectory . $NewFileName; try { $inputFileType = PHPExcel_IOFactory::identify($inputFileName); $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcel = $objReader->load($inputFileName); // Get worksheet dimensions $sheet = $objPHPExcel->getSheet(0); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); // Loop through each row of the worksheet in turn for ($row = 1; $row <= $highestRow; $row++) { // Read a row of data into an array $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); foreach ($rowData[0] as $k => $v) { //$resp .= "Row: ".$row."- Col: ".($k+1)." = ".$v."<br />"; $res = AddToUsers($v, "C"); if ($res == "1") { $i = $i + 1; } else { $j = $j + 1; $userDefault .= $v . ", "; } $resp = AddToTable($v, $organ, $course, "Mentor"); if ($resp == "1") { $k = $k + 1; } else { $l = $l + 1; $menteeDefault .= $v . ", "; } } // end of foreach