In this article · 8 sections
Bookings, enquiries, products, blog posts: dynamic websites store data in a database, and MySQL (or its close relative MariaDB) is the most common choice on Indian hosting. These MySQL basics cover what you need to build real features.
Key terms
- Database: a container for your tables (e.g.
taxi_site) - Table: like a spreadsheet sheet (e.g.
bookings) - Row: one record (one booking)
- Column: one field (phone, pickup city)
- Primary key: a unique ID for each row
Create a table
CREATE TABLE bookings (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
phone VARCHAR(15) NOT NULL,
pickup VARCHAR(100),
drop_city VARCHAR(100),
travel_date DATE,
status ENUM('new','confirmed','cancelled') DEFAULT 'new',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Use utf8mb4 so Hindi, Punjabi and emoji are stored correctly.
CRUD: Create, Read, Update, Delete
INSERT INTO bookings (name, phone, pickup, drop_city, travel_date)
VALUES ('Aman', '9876543210', 'Ludhiana', 'Delhi', '2026-11-05');
SELECT id, name, drop_city FROM bookings
WHERE status = 'new' ORDER BY created_at DESC LIMIT 20;
UPDATE bookings SET status = 'confirmed' WHERE id = 15;
DELETE FROM bookings WHERE id = 15;
Always use WHERE with UPDATE and DELETE, or you'll change every row.
Indexes for speed
CREATE INDEX idx_status_created ON bookings (status, created_at);
Index columns you filter or sort by often. See database optimisation for PHP sites.
Connecting from PHP safely
<?php
$conn = new mysqli('localhost', 'db_user', 'db_pass', 'taxi_site');
$conn->set_charset('utf8mb4');
$stmt = $conn->prepare(
"INSERT INTO bookings (name, phone, pickup, drop_city, travel_date) VALUES (?, ?, ?, ?, ?)"
);
$stmt->bind_param('sssss', $name, $phone, $pickup, $drop, $date);
$stmt->execute();
Prepared statements keep user input separate from SQL and prevent SQL injection. See PHP security.
Reading rows:
<?php
$stmt = $conn->prepare("SELECT name, drop_city FROM bookings WHERE status = ?");
$status = 'new';
$stmt->bind_param('s', $status);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
echo htmlspecialchars($row['name']) . ' → ' . htmlspecialchars($row['drop_city']) . '<br>';
}
phpMyAdmin
On most hosting panels, phpMyAdmin lets you browse tables, run queries, import and export. Export a backup before big changes. See how to back up a website.
Next step
Combine data from multiple tables with SQL JOINs.
FAQs
MySQL or MariaDB?
They're highly compatible for typical websites. Many hosts use MariaDB under the "MySQL" name.
Should I store images in the database?
Usually no. Store files on disk and save the file path in the database.
Was this article helpful?
Your answer helps us improve our guides