Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 7.99 KB

03-mysql.md

File metadata and controls

35 lines (29 loc) · 7.99 KB

Stars Badge Forks Badge Pull Requests Badge Issues Badge GitHub contributors Visitors

Don't forget to hit the ⭐ if you like this repo.

PHP & MySQL

Lesson Topic Description Result
12a Connecting to MySQL Database Server In PHP you can easily do this using the mysqli_connect() function. All communication between PHP and the MySQL database server takes place through this connection.
12b Closing the MySQL Database Server Connection The connection to the MySQL database server will be closed automatically as soon as the execution of the script ends. However, if you want to close it earlier you can do this by simply calling the PHP mysqli_close() function.
12c Creating MySQL Database Using PHP Before saving or accessing the data, we need to create a database first. The CREATE DATABASE statement is used to create a new database in MySQL. Let's make a SQL query using the CREATE DATABASE statement, after that we will execute this SQL query through passing it to the PHP mysqli_query() function to finally create our database. Database: demo1.
12d PHP MySQL Create Tables A table organizes the information into rows and columns. The SQL CREATE TABLE statement is used to create a table in the database. Database: demo1, table: persons.
12e Inserting Data into a MySQL Database Table The INSERT INTO statement is used to insert new rows in a database table. Database: demo1, table: persons.
12f Inserting Multiple Rows into a Table To do this, include multiple lists of column values within the INSERT INTO statement, where column values for each row must be enclosed within parentheses and separated by a comma. Database: demo1, table: persons.
12g PHP MySQL Prepared Statements A prepared statement (also known as a parameterized statement) is simply a SQL query template containing placeholders instead of the actual parameter values. These placeholders will be replaced by the actual values at the time of execution of the statement. Prepared statements also provide strong protection against SQL injection because parameter values are not embedded directly inside the SQL query string. Database: demo1, table: persons.
12h PHP MySQL Last Inserted ID For this example, we'll use the same persons table that we've created in the PHP MySQL create tables chapter, which has four columns id, first_name, last_name, and email, where id is the primary key column and marked with the AUTO_INCREMENT flag. Database: demo1, table: persons.
12i Selecting Data From Database Tables Now it's time to retrieve data that we have inserted in the preceding tutorial. The SQL SELECT statement is used to select records from database tables. Database: demo1, table: persons.
12j Filtering the Records In this tutorial, you will learn how to select records from a MySQL database table based on specific conditions using PHP. The WHERE clause is used to extract only those records that fulfill a specified condition. Database: demo1, table: persons.
12k Limiting Result Sets The LIMIT clause is used to constrain the number of rows returned by the SELECT statement. Database: demo1, table: persons.
12l Ordering the Result Set The ORDER BY clause can be used in conjunction with the SELECT statement to see the data from a table ordered by a specific field. The ORDER BY clause lets you define the field name to sort against and the sort direction, either ascending or descending. Database: demo1, table: persons.
12m Updating Database Table Data The UPDATE statement is used to change or modify the existing records in a database table. This statement is typically used in conjunction with the WHERE clause to apply the changes to only those records that match specific criteria. Database: demo1, table: persons.
12n Deleting Database Table Data Just as you insert records into tables, you can delete records from a table using the SQL DELETE statement. It is typically used in conjunction with the WHERE clause to delete only those records that match specific criteria or condition. Database: demo1, table: persons.

Contribution 🛠️

Please create an Issue for any improvements, suggestions or errors in the content.

You can also contact me using Linkedin for any other queries or feedback.

Visitors