SQL AND PHP
SQL (Structured Query Language) is a tool used to manage, store, retrieve, and manipulate data within
databases.
To set up a database named BAUK with specific columns like Name, Age, State, and Gender, the steps
are as follows:
1. Create a Database:
Use: CREATE DATABASE BAUK;
2. Show Available Databases:
Command: SHOW DATABASES;
3. Connect to the Database:
Command: USE BAUK;
4. Create a Table:
CREATE TABLE bauk (
firstname VARCHAR(20),
lastname VARCHAR(20),
age INT(5),
state VARCHAR(15),
gender VARCHAR(20)
);
5. Insert Data:
Command: INSERT INTO bauk VALUES (...);
To query the data:
Use SELECT * to retrieve all records from the table.
Using SQL Consoles:
When interacting with databases, the SQL command line is powerful, but tools like PHPMyAdmin
provide a more user-friendly experience for managing databases.
Keys in SQL:
Primary Key: Ensures each record is uniquely identified.
Unique Key: Ensures no duplicate values in a column (commonly used for emails).
Foreign Key: Links records across two tables.
NOT NULL: Prevents a column from having empty values.
Default Value: Assigns a pre-defined value if none is provided.
---
Web Development with HTML and CSS
CSS Overview
Cascading Style Sheets (CSS) are used to design and enhance the appearance of HTML elements. It
handles aspects like layout, colors, fonts, spacing, and overall styling to improve user experience.
Types of CSS:
1. Internal CSS: Written directly within an HTML document.
2. External CSS: Created in a separate file and linked to the HTML.
3. Inline CSS: Applied directly to an HTML element.
---
HTML: Creating Tables and Forms
To Create a Table:
HTML uses the <table> tag for table structures. Example:
<table border="2" width="400">
<tr>
<th>Name</th>
<th>Surname</th>
<th>Age</th>
</tr>
<tr>
<td>SALMA</td>
<td>Atana</td>
<td>18</td>
</tr>
</table>
<tr>: Represents a table row.
<th>: Defines a table header.
<td>: Adds data to a table cell.
To Create a Form:
Use the <form> tag to accept user inputs. Example:
<form name="SALMA" method="post">
<label>First Name:</label>
<input type="text" name="fname" size="50" maxlength="10" />
</form>
Method Attribute: Defines how data is sent (e.g., GET or POST).
GET: Suitable for retrieving data.
POST: Preferred for secure submissions.
---
PHP with Dates
1. Display Current Date:
<?php
echo "Today is " . date("Y/m/d") . "<br>";
echo "Today is " . date("Y.m.d") . "<br>";
echo "Today is " . date("Y-m-d") . "<br>";
echo "Today is " . date("l");
?>
2. Show Dates for the Next 6 Saturdays:
<?php
$startdate = strtotime("Saturday");
$enddate = strtotime("+6 weeks", $startdate);
while ($startdate < $enddate) {
echo date("M d", $startdate) . "<br>";
$startdate = strtotime("+1 week", $startdate);
}
?>
---
Let me know if you want further adjustments or additional changes!