Up-to-date listing php. PHP glob – folder listing. Find the list of folders for additional PHP help

Golovna / Google Play

For all leaves, this is a great way to cover your business points. In this section, we will use our best efforts to include PHP, MySQL, and AJAX. This tutorial assumes that you have a basic understanding of HTML, PHP, MySQL, and JavaScript.

We will be using the following files through this tutorial. You can download them using the link below. Press in order to avoid harming alternative structures, but remember before changing your file while in text code.

Main Index File

First of all, what is needed is to think about the structure for our main index page ( index.php). This function will be on one page only and will rely on AJAX to pick and drop elements. Open the index.php file and add the following code.

Simple To-Do List

Note: In order to record the hour, we don’t have to squeeze it into this style. A CSS file may be included in the file files.

Connecting to the MySQL Database

We must configure the MySQL Database to collect our elements. By the way, a simple server-side tool is called phpMyAdmin. Tools comes pre-installed on most web hosts and bundled with local development services such as WampServer and XAMPP. We will be setting up one table with the name of 'tasks' and the following columns in this order: 'id', 'task', 'date', 'time'. Please, press the id column to auto-increment (be sure to checkbox labeled 'A_I').

After creating a new table, we need to connect our project to the database. Open connect.php and add the following code to the file. Be sure to exchange your database materials for 'username', 'password', 'database_name' fields. Save the file when you are done.

Explaining the Code
PHP has a function mysql_connect() that can be created to connect to MySQL Server. Web-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server-server different files. Because of this, substitute has the same value for MySQL Server's IP address. After the connection has been split, the mysql_select_db() function selects a specific database from the server.

Now that we have created our connect.php file, we need to add it to the main index file. Add the following code to index.php and save the change.

Simple To-Do List

Adding a New To-Do Item

Further you will go to the extent that you create a method to add to our sheets. For this purpose, we will analyze both the form and the results to the database. Add the following code to index.php and save the change.

Simple To-Do List

Note: It is estimated that the form does not have an action or attribute method. There are typically wikis for submitting data to another file via a post or get request. We must use AJAX in order to dumb down our form, so they cannot be used for these signs. For more information on AJAX, download this material from W3Schools.

Open index.php in your web browser and have a look. At this point, you must be aware of the large white rectangle, where all elements will be created and a text field for creating new elements in the list.

In order to quickly establish a method for communication with him. For more jQuery help, let's send our new to-do item via a post request to the add-task.php file. Of these, our focus will be formatting and adding to programs. Add the following to the index.php file directly after the closing tag.

Explaining the Code
Script above intercepts the field field value on form submit and sends it to add-task.php using the $.post() jQuery method. The add-task.php file the sends back confirmation of the newly added item, so it may be added to the list. The beautiful thing is that all of this happens without refreshing the page!

Now that our form is sending the new to-do item to add-task.php, we need to tell that file what to do with the information. Open add-task.php and add the following code. Remember to save the file.

© 2024 androidas.ru - All about Android