$arrayProject = $databaseProject->listRecord($databaseProject->query($queryProject)); $message = ''; $titleType = $_GET['type'] == "insert" ? 'Insert' : ($_GET['type'] == 'edit' ? 'Edit' : ''); if (isset($_POST['form_insert']) && isset($_POST['google_insert']) && trim($_POST['google_link']) != '' && trim($_POST['google_date']) != '' && $_POST['google_project'] != '') { $arraySource = array(); $arrayDate = explode(' ', $_POST['google_date']); $month = $arrayDate[0]; $year = $arrayDate[1]; foreach ($_POST as $key => $value) { $arraySource['link'] = $_POST['google_link']; $arraySource['link_month'] = $month; $arraySource['link_year'] = $year; $arraySource['project_link'] = $_POST['google_project']; } $querySource = "SELECT * FROM source_link WHERE `link_month` = '{$month}' AND `project_link` = {$_POST['google_project']}"; if ($databaseSource->checkRow($querySource) == true) { $arrayWhere = array(array('link_month', $month, 'AND'), array('project_link', $_POST['google_project'], null)); $databaseSource->update($arraySource, $arrayWhere); if ($databaseSource->affectedRows() > 0) { $message = '<div class="alert alert-success"> <button class="close" data-dismiss="alert"></button> Update successful! </div>'; } } else { $databaseSource->insert($arraySource, 'single'); if ($databaseSource->affectedRows() > 0) { $message = '<div class="alert alert-success"> <button class="close" data-dismiss="alert"></button> Insert successful! </div>';