0% found this document useful (0 votes)
10 views4 pages

SQL and PHP

The document provides an overview of SQL and PHP, detailing how to create and manage a database, including commands for creating tables and inserting data. It also covers web development with HTML and CSS, explaining how to style elements and create tables and forms. Additionally, it includes PHP examples for displaying the current date and generating future dates.

Uploaded by

tijjanifatima01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views4 pages

SQL and PHP

The document provides an overview of SQL and PHP, detailing how to create and manage a database, including commands for creating tables and inserting data. It also covers web development with HTML and CSS, explaining how to style elements and create tables and forms. Additionally, it includes PHP examples for displaying the current date and generating future dates.

Uploaded by

tijjanifatima01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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!

You might also like