query( "SELECT * FROM branch WHERE deleted_at IS NULL " . $user_branch_permission_sql_123 ) ; if ( $get_branch->num_rows > 0 ){ while ( $row_branch = $get_branch->fetch_assoc() ){ $branch_all[$row_branch['branch_id']] = $row_branch['branch_name'] ; } } // check permission if ( !permissionCheck($row_user, 'association-list-gallery-category') ){ header('Location: index.php') ; exit ; } // mode type | all list | new | edit switch( $page_mode ){ // edit association category case 'new' : case 'edit' : // check query exsits $submit_type = 'new' ; $mysqli_page = $mysqli->query("SELECT * FROM association_gallery_category WHERE category_id = '".$category_id."' LIMIT 1"); if ($mysqli_page->num_rows > 0){ // keep query value in array $row_page = $mysqli_page->fetch_array(MYSQLI_ASSOC) ; $submit_type = 'edit' ; } // update database if ( isset($type) && ( $type == 'new' || $type == 'edit' ) && $_POST['hide'] == 1 ){ // keep value in variable $page_title = escapeString($_POST['title']) ; $page_title = ($page_title != '' ? $page_title : 'No Title') ; if ( $category_id == '' ){ $mysqli->query( "INSERT INTO association_gallery_category ( created_at ) VALUES ( '".TODAYDATE."' )" ) ; $category_id = $mysqli->insert_id ; } $array_branch = [] ; foreach ( $_POST['branch'] as $k_branch => $v_branch ){ $array_branch[] = escapeString( $v_branch ) ; } // update database $mysqli->query( "UPDATE association_gallery_category SET branch = '/".implode('/', $array_branch)."/', status = '".escapeString($_POST['status'])."' WHERE category_id = '".$category_id."'" ) ; foreach ( $LANGS as $klang => $vlang ){ $title = escapeString( $_POST['title_'.$klang] ) ; checkLangUpdate( 'association_gallery_category_translation', 'category_id', $category_id, $klang, [ 'title' => [ 'type' => 'input', 'value' => $title ] ] ) ; } // refresh page header("Location:app-association-gallery-category.php?page_mode=edit&category_id=".$category_id."&success=1") ; $_SESSION['system_result'] = 'success-updated' ; exit ; } // start header here include 'requires/page_header.php'; include 'requires/page_top.php'; ?>