Hướng dẫn html calendar with events from database - lịch html với các sự kiện từ cơ sở dữ liệu
9 ở Pakistan READ ME for HBEventsCalendar: To Begin Import data from event_calendar.sql to your DB. check the test files to see how to use specific functionalities. Configure the `$config` variable for DB information and other settings. event_calendar.sql contains some dummy data and the structure for the table. It is inside import_to_db directory. Regards
Cấp 5 Giải thưởng Đổi mới: 4xKhởi tạo plugin với các tùy chọn và thêm các sự kiện của riêng bạn bằng đối tượng mảng JS ..Event Calendar lists the events date-wise in a large calendar view. The events are fetched dynamically and listed under the date cell. An event calendar makes it easier to find the events for a specific date. You can build a custom event calendar with dynamic data using PHP and MySQL. In the previous tutorial, we learn how to build an event calendar with PHP and MySQL. This tutorial will show you how to create an event calendar with PHP using the FullCalendar JavaScript library. Làm cách nào để lập trình một lịch trong PHP? Đầu tiên sao chép mã nguồn bên dưới vào tệp lớp "Lịch.php". Chúng tôi sẽ đi qua từng chức năng quan trọng. Lớp "Lịch" này là một đối tượng hoàn chỉnh, sẽ lặp lại lịch HTML khi gọi hàm "show ()" của nó.PHP event calendar with FullCalendar.
Tạo một lịch lớn với thư viện FullCalendar JS. php_event_calendar_with_fullcalendar/ ├── index.html ├── fetchEvents.php ├── eventHandler.php ├── dbConfig.php ├── js/ │ ├── fullcalendar/ │ └── sweetalert2.all.min.js └── css/ └── style.css Hiển thị các sự kiện trong ô ngày của lịch.Xem, thêm và xóa các sự kiện khỏi lịch. CREATE TABLE `events` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL, `url` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `start` date NOT NULL, `end` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; Cấu hình cơ sở dữ liệu (dbconfig.php)Tệp này được sử dụng để kết nối với cơ sở dữ liệu bằng PHP và MySQL. Chỉ định máy chủ cơ sở dữ liệu (db_host), tên người dùng (db_username), mật khẩu (db_password) và tên (db_name) theo thông tin đăng nhập cơ sở dữ liệu của bạn. // Database configuration Xây dựng lịch sự kiện (index.html)Hộp thoại: Bao gồm thư viện plugin Sweetalert2 để khởi tạo và sử dụng nó cho các hộp bật lên. Include the sweetalert2 plugin library to initialize and use it for popup boxes. <script src="js/sweetalert2.all.min.js">script> Plugin lịch: Bao gồm thư viện FullCalendar JS & CSS để xây dựng lịch có kích thước đầy đủ bằng JavaScript. Include FullCalendar JS & CSS library to build full-sized calendar using JavaScript. <link href="js/fullcalendar/lib/main.css" rel="stylesheet" /> <script src="js/fullcalendar/lib/main.js">script> Hộp đựng lịch: Xác định một phần tử HTML để đính kèm lịch sự kiện. Define an HTML element to attach the event calendar. <div id="calendar">div> Khởi tạo lớp FullCalendar trên sự kiện DomContentLoaded và hiển thị lịch trên trang web. <script> document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', height: 650, }); calendar.render(); }); script> Trong các ví dụ sau, chúng ta sẽ thấy cách tích hợp danh sách sự kiện, chi tiết, thêm và xóa chức năng vào FullCalendar bằng JavaScript. Tìm nạp các sự kiện từ phía máy chủ và liệt kê chúng trên lịch:
document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', height: 650, events: 'fetchEvents.php', }); calendar.render(); }); Thêm sự kiện:
document.addEventListener('DOMContentLoaded', function() { var calendarEl = document.getElementById('calendar'); var calendar = new FullCalendar.Calendar(calendarEl, { initialView: 'dayGridMonth', height: 650, events: 'fetchEvents.php', selectable: true, select: async function (start, end, allDay) { const { value: formValues } = await Swal.fire({ title: 'Add Event', html: '' + '' + '', focusConfirm: false, preConfirm: () => { return [ document.getElementById('swalEvtTitle').value, document.getElementById('swalEvtDesc').value, document.getElementById('swalEvtURL').value ] } }); if (formValues) { fetch("eventHandler.php", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ request_type:'addEvent', start:start.startStr, end:start.endStr, event_data: formValues}), }) .then(response => response.json()) .then(data => { if (data.status == 1) { Swal.fire('Event added successfully!', '', 'success'); } else { Swal.fire(data.error, '', 'error'); } calendar.refetchEvents(); }) .catch(console.error); } } }); calendar.render(); }); Xem chi tiết sự kiện:
php_event_calendar_with_fullcalendar/ ├── index.html ├── fetchEvents.php ├── eventHandler.php ├── dbConfig.php ├── js/ │ ├── fullcalendar/ │ └── sweetalert2.all.min.js └── css/ └── style.css0 Dựa trên trạng thái, thông báo được hiển thị trên cửa sổ bật lên.
php_event_calendar_with_fullcalendar/ ├── index.html ├── fetchEvents.php ├── eventHandler.php ├── dbConfig.php ├── js/ │ ├── fullcalendar/ │ └── sweetalert2.all.min.js └── css/ └── style.css1 Xem chi tiết sự kiện:Sử dụng chức năng gọi lại CREATE TABLE `events` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL, `url` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `start` date NOT NULL, `end` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;3 để đính kèm tính năng chi tiết xem sự kiện. Khi nhấp, các chi tiết sự kiện được hiển thị trên hộp bật lên.
php_event_calendar_with_fullcalendar/ ├── index.html ├── fetchEvents.php ├── eventHandler.php ├── dbConfig.php ├── js/ │ ├── fullcalendar/ │ └── sweetalert2.all.min.js └── css/ └── style.css2 Xóa sự kiện: Nút xóa được đặt trong các chi tiết sự kiện bật lên. // Database configuration2.
Tìm nạp các sự kiện (Fetchevents.php): // Database configuration3.
php_event_calendar_with_fullcalendar/ ├── index.html ├── fetchEvents.php ├── eventHandler.php ├── dbConfig.php ├── js/ │ ├── fullcalendar/ │ └── sweetalert2.all.min.js └── css/ └── style.css3 Tìm nạp các sự kiện (Fetchevents.php): Tìm nạp các sự kiện từ cơ sở dữ liệu.Kết xuất dữ liệu sự kiện ở định dạng JSON bằng hàm json_encode ().event calendar with PHP using the FullCalendar plugin. The example code shows how to integrate list/view/add/delete functionality with the FullCalendar library using PHP and MySQL. You can allow the user to manage events on a full-sized calendar dynamically. The functionality of the event calendar can be enhanced easily with FullCalendar as per your needs. Tệp CREATE TABLE `events` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `description` varchar(500) COLLATE utf8_unicode_ci DEFAULT NULL, `url` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `start` date NOT NULL, `end` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;1 được sử dụng để xử lý thêm và xóa chức năng. Dựa trên tham số // Database configuration1, khối mã được thực thi. Thêm sự kiện (EventHandler.php): Yêu cầu được chấp nhận nếu // Database configuration2. Làm thế nào để bạn tạo một lịch sự kiện trong HTML?Bằng cách sử dụng mã của FullCalendar, bạn có thể thiết lập lịch sự kiện trên trang của mình. Bây giờ nếu bạn muốn thiết lập thì hãy làm theo một số bước đơn giản. Bước 2: Bây giờ bạn cần thêm một số tệp CSS và các tệp JS hữu ích để hiển thị lịch sự kiện. Xin lưu ý rằng mã sẽ được thêm vào thẻ bên trong.. Now if you want to setup then follow some simple steps. Step 2: Now you need to add some css file and js files which is helpful for displaying event calendar. Please note that code will be add inside tag.
Làm thế nào để tôi nhúng một sự kiện vào lịch?Nhúng một lịch trên trang web của bạn.. Trên máy tính, hãy mở Lịch Google..... Ở trên cùng bên phải, nhấp vào cài đặt..... Ở phía bên trái của màn hình, nhấp vào tên của lịch bạn muốn nhúng .. Trong phần "Lịch tích hợp", sao chép mã iframe được hiển thị .. Trong mã nhúng, nhấp vào Tùy chỉnh .. Làm thế nào có thể thêm sự kiện trong lịch jQuery?Làm thế nào để sử dụng nó:.. Trong mã nhúng, nhấp vào Tùy chỉnh .. Tạo một yếu tố trống sẽ được phục vụ như một thùng chứa lịch..... Khởi tạo plugin với các tùy chọn và thêm các sự kiện của riêng bạn bằng đối tượng mảng JS .. Làm cách nào để lập trình một lịch trong PHP?Đầu tiên sao chép mã nguồn bên dưới vào tệp lớp "Lịch.php".Chúng tôi sẽ đi qua từng chức năng quan trọng.Lớp "Lịch" này là một đối tượng hoàn chỉnh, sẽ lặp lại lịch HTML khi gọi hàm "show ()" của nó.copy the source code below to a class file "calendar. php". We will go through each important function. This "Calendar" class is a complete object, which will echo a HTML calendar upon calling its "show()" function. |