Data Analytics
27K subscribers
1.16K photos
24 videos
26 files
977 links
Dive into the world of Data Analytics – uncover insights, explore trends, and master data-driven decision making.
Download Telegram
📚 MySQL Crash Course (2023)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/8

💬 Tags: #mySQL

USEFUL CHANNELS FOR YOU
❤‍🔥6👍1🔥1
📚 MySQL Cookbook (2022)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/26

💬 Tags: #mySQL

USEFUL CHANNELS FOR YOU
❤‍🔥32👍1
📚 The MySQL Workshop (2022)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/156

💬 Tags: #MySQL

USEFUL CHANNELS FOR YOU
👍4
📚 MySQL Crash Course (2023)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/178

💬 Tags: #MySQL

USEFUL CHANNELS FOR YOU
👍51
📚 MySQL Crash Course (2024)

1️⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2️⃣ Download Book: https://t.iss.one/c/1854405158/1387

💬 Tags: #MySQL

👉 BEST DATA SCIENCE CHANNELS ON TELEGRAM 👈
Please open Telegram to view this post
VIEW IN TELEGRAM
👍9
📚 Mastering MySQL Administration (2024)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/1510

💬 Tags: #MySQL

👉 BEST DATA SCIENCE CHANNELS ON TELEGRAM 👈
👍91
📚 MYSQL Guide for Beginner (2024)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/2051

💬 Tags: #MYSQL

USEFUL CHANNELS FOR YOU
👍51
📚 Hacking MySQL (2024)

1⃣ Join Channel Download:
https://t.iss.one/+MhmkscCzIYQ2MmM8

2⃣ Download Book: https://t.iss.one/c/1854405158/2133

💬 Tags: #MySQL

USEFUL CHANNELS FOR YOU
👍11🔥2
MySQL Cheat Sheet

💬 Tags: #MySQL #SQL

USEFUL CHANNELS FOR YOU
👍41
Topic: PHP Basics – Part 10 of 10: Connecting PHP with MySQL Database (CRUD Operations)

---

1. Introduction

PHP works seamlessly with MySQL, one of the most popular open-source relational databases. In this lesson, we’ll learn how to:

• Connect to a MySQL database
• Perform basic CRUD operations (Create, Read, Update, Delete)

We’ll use the mysqli extension (object-oriented style) in this tutorial.

---

### 2. Setting Up the Database

Suppose we have a MySQL database named school with a table students:

CREATE DATABASE school;

USE school;

CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(50),
email VARCHAR(100),
age INT
);


---

### 3. Connecting PHP to MySQL

<?php
$host = "localhost";
$user = "root";
$password = "";
$db = "school";

$conn = new mysqli($host, $user, $password, $db);

if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully!";
?>


---

### 4. Create (INSERT)

<?php
$sql = "INSERT INTO students (name, email, age) VALUES ('Ali', '[email protected]', 22)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully.";
} else {
echo "Error: " . $conn->error;
}
?>


---

### 5. Read (SELECT)

<?php
$sql = "SELECT * FROM students";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "ID: " . $row["id"]. " | Name: " . $row["name"]. " | Email: " . $row["email"]. "<br>";
}
} else {
echo "0 results";
}
?>


---

### 6. Update (UPDATE)

<?php
$sql = "UPDATE students SET age = 23 WHERE name = 'Ali'";
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully.";
} else {
echo "Error updating record: " . $conn->error;
}
?>


---

### 7. Delete (DELETE)

<?php
$sql = "DELETE FROM students WHERE name = 'Ali'";
if ($conn->query($sql) === TRUE) {
echo "Record deleted successfully.";
} else {
echo "Error deleting record: " . $conn->error;
}
?>


---

### 8. Prepared Statements (Best Practice for Security)

Prevent SQL injection by using prepared statements:

<?php
$stmt = $conn->prepare("INSERT INTO students (name, email, age) VALUES (?, ?, ?)");
$stmt->bind_param("ssi", $name, $email, $age);

$name = "Sara";
$email = "[email protected]";
$age = 20;

$stmt->execute();
echo "Data inserted securely.";
$stmt->close();
?>


---

### 9. Closing the Connection

$conn->close();


---

### 10. Summary

• PHP connects easily with MySQL using mysqli.

• Perform CRUD operations for full database interaction.

• Always use prepared statements for secure data handling.

---

### Exercise

1. Create a PHP page to add a student using a form.
2. Display all students in a table.
3. Add edit and delete buttons next to each student.
4. Implement all CRUD operations using mysqli.

---

#PHP #MySQL #CRUD #PHPTutorial #WebDevelopment #Database

https://t.iss.one/Ebooks2023
2