0% found this document useful (0 votes)
13 views

CC 13 2023

The document covers various topics related to web development, including HTML, CSS, PHP, and JavaScript. It explains key concepts such as HTML elements, CSS color codes, PHP string functions, and MySQL commands, along with examples and code snippets. Additionally, it discusses the differences between GET and POST methods, the history of the Internet, and advantages and disadvantages of online communication.

Uploaded by

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

CC 13 2023

The document covers various topics related to web development, including HTML, CSS, PHP, and JavaScript. It explains key concepts such as HTML elements, CSS color codes, PHP string functions, and MySQL commands, along with examples and code snippets. Additionally, it discusses the differences between GET and POST methods, the history of the Internet, and advantages and disadvantages of online communication.

Uploaded by

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

Part -A

(A)
1 Who developed HTML? -> sir Timothy john berners-lee.
2 The CSS unicode color code for green color? -> #00FF00
3 src attribute is used to specify address of any picture file in image element -<img>.
4 HTTPRequest() function is used to send request to the web based data server, using AJAX technology.
5 Cyber Law basically deals in information security, safe data transaction, data encryption.
(B)
1 IP address contains 4 parts separated by dot (.) symbol, known as octets.
2 href attribute is used to specify the URL of any external file (or IP address) in the anchor element <a>.
3 In rgba() / hsla() CSS color code function, 'a' denotes the alpha (opacity) of the entity’s color and has a
value range from 0 (completely transparent) to 1 (completely opaque).
4 PHP is an acronym for Hypertext Preprocessor.
5 Cookies are used to store local machine's data for any web page and are used whenever the page is
rebrowsed on the same machine.
Part - B
1 Differentiate between GET and POST with examples for each ( both PHP and HTML Code).

🔍 Difference between GET and POST:


Feature GET POST

Data visibility Data sent in URL (visible) Data sent in body (hidden)

Data length limit Limited (URL length limit) No significant limit

Use case Fetching/viewing data Sending/modifying sensitive data

Bookmarkable URL? Yes No

Secure for login? ❌ No ✅ Yes

✅ GET Method
🔹 HTML Code:
<form action="get_example.php" method="get">
Name: <input type="text" name="username">
<input type="submit" value="Submit via GET">
</form>

🔹 PHP Code (get_example.php):


<?php
if (isset($_GET['username'])) {
$name = $_GET['username'];
echo "Hello, " . htmlspecialchars($name);
}
?>
✅ POST Method
🔹 HTML Code:
<form action="post_example.php" method="post">
Name: <input type="text" name="username">
<input type="submit" value="Submit via POST">
</form>

🔹 PHP Code (post_example.php):


<?php
if (isset($_POST['username'])) {
$name = $_POST['username'];
echo "Hello, " . htmlspecialchars($name);
}
?>

2 Write short notes on the following : Head element, Types of color codes used in CSS, XML, History of
Internet, its advantages and disadvantage.

📌 1. Head Element (<head>)


●​ The <head> element in HTML contains meta-information about the web page.​

●​ It is placed before the <body> tag.​

●​ It may include:​

○​ <title> (page title in browser tab)​

○​ <meta> tags (like charset, description, keywords)​

○​ <link> to stylesheets (CSS)​

○​ <script> tags (JavaScript)​

○​ <style> tags (internal CSS)​

✅ Example:
<head>
<title>My Web Page</title>
<link rel="stylesheet" href="style.css">
</head>

🎨 2. Types of Color Codes Used in CSS


CSS allows you to define colors in multiple ways:
1.​ Named Colors​

○​ Example: red, blue, green​

2.​ Hexadecimal (Hex) Codes​

○​ Format: #RRGGBB (e.g., #ff0000 = red)​

3.​ RGB Values​

○​ Format: rgb(255, 0, 0)​

4.​ RGBA Values​

○​ Like RGB but with transparency: rgba(255, 0, 0, 0.5)​

5.​ HSL (Hue, Saturation, Lightness)​

○​ Format: hsl(0, 100%, 50%)​

6.​ HSLA​

○​ Adds alpha: hsla(0, 100%, 50%, 0.5)​

🧾 3. XML (eXtensible Markup Language)


●​ XML is a markup language used to store and transport data.​

●​ It is platform-independent and self-descriptive.​

●​ Unlike HTML, XML does not have predefined tags; you define your own.​

✅ Example:
<student>
<name>John</name>
<age>20</age>
</student>

✔ Uses: Configuration files, data interchange, web services (like SOAP).

🌐 4. History of Internet
●​ The Internet originated from ARPANET in the 1960s, developed by the U.S. Department of Defense.​
●​ In 1990, Tim Berners-Lee invented the World Wide Web (WWW).​

●​ The Internet grew rapidly in the 1990s, with the introduction of browsers like Mosaic and Netscape.​

●​ Now, it's a global network used for communication, business, education, and entertainment.​

✅ 5. Advantages and Disadvantages of Internet


Advantages:

●​ Easy and instant communication (email, messaging)​

●​ Access to unlimited information​

●​ Online services (banking, shopping, education)​

●​ Helps in research and learning​

Disadvantages:

●​ Cybersecurity threats (hacking, phishing)​

●​ Addiction to social media and games​

●​ Misinformation or fake news​

●​ Privacy issues​

3 Explain any 5 important string functions in PHP. Write a common PHP code demonstrating the use of all
these function.

✅ 5 Important String Functions in PHP:


1. strlen()

●​ Returns the length of a string.​

strlen("Hello"); // Outputs: 5

2. strrev()

●​ Reverses a string.​
strrev("Hello"); // Outputs: "olleH"

3. strtolower()

●​ Converts a string to lowercase.​

strtolower("HELLO"); // Outputs: "hello"

4. strtoupper()

●​ Converts a string to uppercase.​

strtoupper("hello"); // Outputs: "HELLO"

5. strpos()

●​ Finds the position of the first occurrence of a substring.​

strpos("Hello World", "World"); // Outputs: 6

🧪 PHP Code Demonstrating All 5 Functions:


<?php

$text = "Hello World";

echo "Original Text: " . $text . "<br>";

// 1. Length of the string

echo "Length: " . strlen($text) . "<br>";


// 2. Reverse the string

echo "Reversed: " . strrev($text) . "<br>";

// 3. Convert to lowercase

echo "Lowercase: " . strtolower($text) . "<br>";

// 4. Convert to uppercase

echo "Uppercase: " . strtoupper($text) . "<br>";

// 5. Find position of 'World'

$position = strpos($text, "World");

echo "Position of 'World': " . ($position !== false ? $position : "Not found") . "<br>";

?>

4 Explain 4 different types of List elements with attributes. Give one code demonstrating all.

In HTML, lists are used to organize items in a specific order or structure. There are four types of list
elements in HTML, each with its specific use and attributes.

1. Ordered List (<ol>)

●​ An ordered list is used to display items in a numbered or alphabetical order.​

●​ Attribute:​

○​ type: Specifies the type of list marker (1 = numbers, A = uppercase letters, a = lowercase
letters).​

○​ start: Specifies the starting number for the list.​

○​ reversed: Reverses the order of the list.​

Example:

<ol type="A" start="5">

<li>Apple</li>

<li>Banana</li>

<li>Cherry</li>

</ol>
2. Unordered List (<ul>)

●​ An unordered list is used to display items in no specific order, with bullets or other markers.​

●​ Attribute:​

○​ type: Specifies the bullet style (circle, square, disc).​

Example:

<ul type="square">

<li>Milk</li>

<li>Eggs</li>

<li>Bread</li>

</ul>

3. Description List (<dl>)

●​ A description list is used to define a list of terms and their descriptions.​

●​ Attributes:​

○​ dt: Defines the term/name.​

○​ dd: Defines the description of the term.​

Example:

<dl>

<dt>Coffee</dt>

<dd>A hot beverage made from roasted coffee beans.</dd>

<dt>Tea</dt>

<dd>A hot or cold beverage made from tea leaves.</dd>

</dl>
4. Definition List with Nested Lists

●​ You can nest other lists (ordered, unordered, or definition) inside a description list.​

Example:

<dl>

<dt>Fruits</dt>

<dd>

<ul>

<li>Apple</li>

<li>Banana</li>

<li>Cherry</li>

</ul>

</dd>

<dt>Vegetables</dt>

<dd>

<ol type="1">

<li>Carrot</li>

<li>Broccoli</li>

<li>Spinach</li>

</ol>

</dd>

</dl>

🧪 Code Demonstrating All Four List Elements:


<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>HTML List Examples</title>

</head>

<body>

<h3>1. Ordered List</h3>

<ol type="A" start="5">

<li>Apple</li>

<li>Banana</li>

<li>Cherry</li>

</ol>

<h3>2. Unordered List</h3>

<ul type="square">

<li>Milk</li>

<li>Eggs</li>

<li>Bread</li>

</ul>

<h3>3. Description List</h3>

<dl>

<dt>Coffee</dt>

<dd>A hot beverage made from roasted coffee beans.</dd>

<dt>Tea</dt>

<dd>A hot or cold beverage made from tea leaves.</dd>

</dl>

<h3>4. Nested List inside Description List</h3>

<dl>
<dt>Fruits</dt>

<dd>

<ul>

<li>Apple</li>

<li>Banana</li>

<li>Cherry</li>

</ul>

</dd>

<dt>Vegetables</dt>

<dd>

<ol type="1">

<li>Carrot</li>

<li>Broccoli</li>

<li>Spinach</li>

</ol>

</dd>

</dl>

</body>

</html>

5 Write a PHP Script and supporting HTML Code to enter a number and print its reverse.

Here is a simple PHP script and HTML code to enter a number and print its reverse.

HTML Form (to enter the number):

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Reverse a Number</title>
</head>

<body>

<h2>Enter a Number to Get Its Reverse</h2>

<form action="reverse_number.php" method="post">

<label for="number">Enter Number:</label>

<input type="text" id="number" name="number" required>

<input type="submit" value="Reverse">

</form>

</body>

</html>

PHP Script (reverse_number.php):

<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {

// Get the input number

$number = $_POST['number'];

// Check if the input is a valid number

if (is_numeric($number)) {

// Reverse the number

$reversed = strrev($number);

echo "<h3>Original Number: $number</h3>";

echo "<h3>Reversed Number: $reversed</h3>";

} else {

echo "<h3>Please enter a valid number.</h3>";

}
}

?>

6 Write a Java Script that takes two numbers from its supporting HTML Code and find the greater number.

Here's a simple JavaScript code to take two numbers from the user and find the greater number, along with
the supporting HTML code.

HTML Form (to enter two numbers):

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Find Greater Number</title>

</head>

<body>

<h2>Enter Two Numbers to Find the Greater One</h2>

<form id="numberForm">

<label for="num1">Enter First Number:</label>

<input type="number" id="num1" required><br><br>

<label for="num2">Enter Second Number:</label>

<input type="number" id="num2" required><br><br>

<input type="button" value="Find Greater" onclick="findGreater()">

</form>

<h3 id="result"></h3>

<script>
function findGreater() {

// Get the values from the input fields

var num1 = document.getElementById('num1').value;

var num2 = document.getElementById('num2').value;

// Convert the values to numbers

num1 = parseFloat(num1);

num2 = parseFloat(num2);

// Check if both values are valid numbers

if (isNaN(num1) || isNaN(num2)) {

document.getElementById('result').innerHTML = "Please enter valid numbers in both fields.";

} else {

// Compare the numbers and display the greater one

if (num1 > num2) {

document.getElementById('result').innerHTML = "The greater number is: " + num1;

} else if (num2 > num1) {

document.getElementById('result').innerHTML = "The greater number is: " + num2;

} else {

document.getElementById('result').innerHTML = "Both numbers are equal.";

</script>

</body>

</html>

Part - C

1 Explain of the following in detail and give example for each: Table element and its child elements, Three
important MySQL's SQL commands, Selectors in CSS, Global constants of PHP.
Sure! Let's go through each of these topics in detail, with examples for better understanding.

---

### 1. **Table Element and its Child Elements in HTML**

In HTML, the `<table>` element is used to create a table structure, and it contains several child elements to
define the table's structure.

#### **Child Elements of `<table>`:**

1. **`<thead>`**: Represents the **header** section of the table, typically containing column headers.

2. **`<tbody>`**: Represents the **body** of the table, containing the main content.

3. **`<tfoot>`**: Represents the **footer** section, typically used for summary or totals.

4. **`<tr>`**: Defines a **table row**, which can be used within `<thead>`, `<tbody>`, or `<tfoot>`.

5. **`<th>`**: Defines a **table header cell**. Text in a `<th>` is bold and centered by default.

6. **`<td>`**: Defines a **table data cell**. Contains the actual content of the table.

#### **Example:**

```html

<table border="1">

<thead>

<tr>

<th>Product</th>

<th>Price</th>

</tr>

</thead>

<tbody>

<tr>

<td>Apple</td>

<td>$1.00</td>
</tr>

<tr>

<td>Banana</td>

<td>$0.50</td>

</tr>

</tbody>

<tfoot>

<tr>

<td>Total</td>

<td>$1.50</td>

</tr>

</tfoot>

</table>

```

### Explanation:

- **`<thead>`**: Contains header row with column names.

- **`<tbody>`**: Contains the actual data rows.

- **`<tfoot>`**: Provides a footer with the total.

---

### 2. **Three Important MySQL SQL Commands**

MySQL uses SQL (Structured Query Language) to interact with databases. Here are three essential SQL
commands:

#### 1. **SELECT**:

Used to retrieve data from a database.


```sql

SELECT * FROM employees WHERE department = 'Sales';

```

- This retrieves all columns (`*`) from the `employees` table where the `department` is 'Sales'.

#### 2. **INSERT INTO**:

Used to insert new data into a table.

```sql

INSERT INTO employees (name, department, salary)

VALUES ('John Doe', 'Sales', 50000);

```

- This inserts a new row into the `employees` table with values for `name`, `department`, and `salary`.

#### 3. **UPDATE**:

Used to modify existing data in a table.

```sql

UPDATE employees

SET salary = 55000

WHERE name = 'John Doe';

```

- This updates the `salary` of the employee with the name 'John Doe' to 55000.

---

### 3. **Selectors in CSS**

CSS selectors are patterns used to select and style HTML elements. Here are some important CSS selectors:
#### 1. **Universal Selector (`*`)**:

Selects all elements on the page.

```css

*{

color: red;

```

- This will make all text on the page red.

#### 2. **ID Selector (`#id`)**:

Selects an element with a specific `id`.

```css

#header {

background-color: blue;

```

- This applies a blue background color to the element with `id="header"`.

#### 3. **Class Selector (`.class`)**:

Selects all elements with a specific `class`.

```css

.button {

padding: 10px;

background-color: green;

```

- This applies padding and a green background to all elements with the `class="button"`.
#### 4. **Attribute Selector (`[attribute]`)**:

Selects elements with a specific attribute.

```css

input[type="text"] {

border: 1px solid #ccc;

```

- This applies a border to all `<input>` elements with `type="text"`.

#### 5. **Pseudo-class Selector (`:hover`, `:first-child`, etc.)**:

Selects elements in a specific state.

```css

a:hover {

color: red;

```

- This changes the link color to red when the user hovers over it.

---

### 4. **Global Constants of PHP**

PHP has several **global constants** that are built into the language. Here are some important ones:

#### 1. **`PHP_VERSION`**:

Contains the current version of PHP.


```php

echo 'PHP Version: ' . PHP_VERSION;

```

- Displays the current version of PHP installed on the server.

#### 2. **`PHP_OS`**:

Contains the operating system PHP is running on.

```php

echo 'Operating System: ' . PHP_OS;

```

- Displays the operating system (e.g., Linux, Windows).

#### 3. **`PHP_EOL`**:

Represents the **End of Line** character(s) used by the platform.

```php

echo 'Hello' . PHP_EOL . 'World';

```

- Ensures the correct line-ending characters are used across different platforms (Windows uses `\r\n`,
Unix-based uses `\n`).

#### 4. **`NULL`**:

Represents a variable with **no value**.

```php

$var = NULL;

if (is_null($var)) {

echo 'Variable is null.';

}
```

- Checks whether a variable is null.

#### 5. **`TRUE` and `FALSE`**:

Represents the boolean constants **true** and **false**.

```php

if (TRUE) {

echo 'This is true.';

} else {

echo 'This is false.';

```

- These are used to represent boolean values `true` and `false` in PHP.

---

2 Explain 7 important functions of PHP, with example, choosing at least one from each of the following
categories: String, Number, Date and Time, Math, Database related and Miscellaneous.

1. String Function: strlen()

The strlen() function is used to get the length of a string (i.e., the number of characters it contains).

Example:

$string = "Hello, World!";

echo strlen($string); // Outputs: 13

●​ Explanation: The string "Hello, World!" has 13 characters, so strlen() returns 13.​

2. Number Function: round()


The round() function rounds a floating-point number to the nearest integer or to a specified number of
decimal places.

Example:

$number = 3.14159;

echo round($number, 2); // Outputs: 3.14

●​ Explanation: The number 3.14159 is rounded to 2 decimal places, resulting in 3.14.​

3. Date and Time Function: date()

The date() function formats a local date and time based on the format provided.

Example:

echo date("Y-m-d H:i:s"); // Outputs: 2025-04-12 12:30:00 (current date and time)

●​ Explanation: The date() function formats the current date and time as Year-Month-Day
Hour:Minute:Second.​

4. Math Function: rand()

The rand() function generates a random integer between a specified range.

Example:

echo rand(1, 100); // Outputs: a random number between 1 and 100

●​ Explanation: The rand(1, 100) generates a random number between 1 and 100 (inclusive).​

5. Database-Related Function: mysqli_connect()

The mysqli_connect() function is used to establish a connection to a MySQL database.

Example:

$connection = mysqli_connect("localhost", "root", "", "my_database");


if (!$connection) {

die("Connection failed: " . mysqli_connect_error());

} else {

echo "Connected successfully!";

●​ Explanation: This establishes a connection to the MySQL database my_database using the
username root and no password (""). If the connection fails, it displays an error message.​

6. Miscellaneous Function: isset()

The isset() function checks if a variable is set and is not null.

Example:

$variable = "Hello";

if (isset($variable)) {

echo "Variable is set.";

} else {

echo "Variable is not set.";

●​ Explanation: Since $variable is set, isset() returns true, and the message "Variable is set." is
displayed.​

7. Miscellaneous Function: array_push()

The array_push() function is used to add one or more elements to the end of an array.

Example:

$array = [1, 2, 3];

array_push($array, 4, 5);

print_r($array);
●​ Explanation: The array_push() function adds the values 4 and 5 to the end of the array. The
resulting array will be [1, 2, 3, 4, 5].

3 Explain PHP arrays, its types and their usage. Explain the usage of each by giving separate PHP Codes for
each type of array.

1. Indexed Arrays

An indexed array is an array where each element is automatically assigned a numeric index starting from 0.

Usage:

Indexed arrays are useful when you have a collection of values where the order matters and the elements can
be accessed by their index.

Example (Indexed Array):

<?php

// Creating an indexed array

$fruits = ["Apple", "Banana", "Cherry"];

// Accessing elements using index

echo $fruits[0]; // Outputs: Apple

echo $fruits[1]; // Outputs: Banana

echo $fruits[2]; // Outputs: Cherry

// Adding an element

$fruits[] = "Orange"; // Adds "Orange" to the array

echo $fruits[3]; // Outputs: Orange

?>

●​ Explanation: The array $fruits holds a list of fruit names, and you can access each fruit using its
index ($fruits[0], $fruits[1], etc.). The last [] syntax adds an element to the array.​

2. Associative Arrays

An associative array is an array where each element is associated with a key (or index) rather than a
numeric index. This allows for more meaningful keys instead of using numbers.
Usage:

Associative arrays are used when you want to use custom keys, such as names or any other descriptive
identifiers, to access the elements.

Example (Associative Array):

<?php

// Creating an associative array

$person = [

"name" => "John",

"age" => 25,

"city" => "New York"

];

// Accessing elements using keys

echo $person["name"]; // Outputs: John

echo $person["age"]; // Outputs: 25

echo $person["city"]; // Outputs: New York

// Adding a new key-value pair

$person["occupation"] = "Developer";

echo $person["occupation"]; // Outputs: Developer

?>

●​ Explanation: The array $person uses keys like "name", "age", and "city" to store associated
values. You can access these values using the keys ($person["name"]).​

3. Multidimensional Arrays

A multidimensional array is an array containing one or more arrays. Essentially, it's an array of arrays, which
is useful when you need to store more complex data structures, such as tables or matrices.

Usage:

Multidimensional arrays are used when you need to store data in a grid-like structure, such as a table with
rows and columns.
Example (Multidimensional Array):

<?php

// Creating a multidimensional array

$students = [

["name" => "John", "age" => 20, "grade" => "A"],

["name" => "Jane", "age" => 22, "grade" => "B"],

["name" => "Tom", "age" => 21, "grade" => "A"]

];

// Accessing elements in a multidimensional array

echo $students[0]["name"]; // Outputs: John

echo $students[1]["grade"]; // Outputs: B

echo $students[2]["age"]; // Outputs: 21

// Adding a new student

$students[] = ["name" => "Emma", "age" => 23, "grade" => "C"];

echo $students[3]["name"]; // Outputs: Emma

?>

●​ Explanation: The array $students contains multiple associative arrays. Each student has attributes
like "name", "age", and "grade". The first student can be accessed using
$students[0]["name"].​

Summary of Arrays:

1.​ Indexed Arrays: Arrays with numeric indices starting from 0. Useful when order matters.​

○​ Example: List of fruits or numbers.​

○​ Code: ["Apple", "Banana", "Cherry"].​

2.​ Associative Arrays: Arrays with custom keys, allowing you to associate values with specific names.​
○​ Example: A person’s details with keys like name, age, city.​

○​ Code: ["name" => "John", "age" => 25].​

3.​ Multidimensional Arrays: Arrays that contain other arrays, allowing you to store complex data
structures like tables.​

○​ Example: A list of students where each student is represented as an associative array with
keys like name, age, and grade.​

○​ Code: [[ "name" => "John", "age" => 20], [ "name" => "Jane", "age" =>
22]].​

4 What is CSS? Who monitors the specifications used in CSS? What are its different versions available in the
market-name them? What are its advantages? What are its types and how they are specified for an HTML
Code? What is the syntax structure of CSS - explain?

Great! Let's dive into CSS in a detailed and organized way to cover all parts of your question:

✅ What is CSS?
CSS stands for Cascading Style Sheets.​
It is a stylesheet language used to control the presentation (look and feel) of HTML elements on a web
page.

With CSS, you can define styles like:

●​ Font styles and sizes​

●​ Colors (text and background)​

●​ Layout (margin, padding, border)​

●​ Positioning and responsiveness​

●​ Animations and transitions​

✅ Who Monitors CSS Specifications?


The World Wide Web Consortium (W3C) is the organization that:

●​ Creates, updates, and maintains the CSS standards/specifications.​

●​ Ensures compatibility across browsers and platforms.​

👉 Visit: www.w3.org
✅ Different Versions of CSS
Version Description

CSS1 Introduced in 1996, basic styling (fonts, colors).

CSS2 Released in 1998, added positioning, z-index, media types, etc.

CSS2.1 Revised version of CSS2 with fixes and improvements.

CSS3 Introduced in modules – each module (like flexbox, animations) can be


updated separately.

CSS4 Not officially released; refers to enhancements and future-level selectors (part
(Draft) of CSS3 modules).

✅ Advantages of CSS
1.​ Separation of content and style (HTML = structure, CSS = design).​

2.​ Reusability – One stylesheet can style multiple pages.​

3.​ Saves time – Make one change and affect the entire site.​

4.​ Improves website performance – Clean and maintainable code.​

5.​ Enhances accessibility and user experience.​

6.​ Supports responsive design for mobile and desktops.​

7.​ Browser compatibility (when following standards).​

✅ Types of CSS and How They Are Specified in HTML


Type How It's Specified Use Case
Inline CSS Directly in HTML tag using the style Quick and specific styling
attribute

Internal CSS Inside <style> tag within <head> section Style for a single HTML page

External CSS Linked using <link> tag to an external Best practice for large
.css file websites

🔹 Example – Inline CSS


<p style="color: red; font-size: 18px;">This is red text.</p>

🔹 Example – Internal CSS


<head>

<style>

p{

color: blue;

</style>

</head>

🔹 Example – External CSS


<head>

<link rel="stylesheet" href="styles.css">

</head>

And in styles.css:

p{

color: green;

}
✅ CSS Syntax Structure
Basic syntax:

selector {

property: value;

🔹 Explanation:
●​ Selector: HTML element you want to style (e.g., p, .class, #id)​

●​ Property: Style attribute you want to set (e.g., color, font-size)​

●​ Value: Value assigned to the property (e.g., red, 16px)​

🔹 Example:
h1 {

color: navy;

font-size: 24px;

text-align: center;

●​ This styles all <h1> elements with navy color, 24px font size, and centered text.​

5 Write the required PHP and HTML Code for inserting 5 records in 'student' table for 'Roll', 'Name', and 'Total'
fields. Name of the database is 'BCA_PU' user name is 'tabulator', password is 'sysadmin' and server name is
'localhost'.

Here’s a simple PHP + HTML form-based script that allows inserting 5 records into the student table with
fields: Roll, Name, and Total, using the database BCA_PU on localhost.

✅ Step 1: HTML Form to Insert 5 Records


<!-- save this as insert_students.html -->

<!DOCTYPE html>

<html>
<head>

<title>Insert Student Records</title>

</head>

<body>

<h2>Enter 5 Student Records</h2>

<form action="insert_students.php" method="POST">

<?php for ($i = 1; $i <= 5; $i++) { ?>

<fieldset>

<legend>Student <?php echo $i; ?></legend>

Roll: <input type="number" name="roll[]" required><br>

Name: <input type="text" name="name[]" required><br>

Total: <input type="number" name="total[]" required><br>

</fieldset>

<br>

<?php } ?>

<input type="submit" value="Insert Records">

</form>

</body>

</html>

✅ Step 2: PHP Script to Handle Insertion


<?php

// save this as insert_students.php

// Database credentials

$server = "localhost";

$username = "tabulator";

$password = "sysadmin";
$database = "BCA_PU";

// Create connection

$conn = mysqli_connect($server, $username, $password, $database);

// Check connection

if (!$conn) {

die("Connection failed: " . mysqli_connect_error());

// Collect data from POST

$rolls = $_POST['roll'];

$names = $_POST['name'];

$totals = $_POST['total'];

// Insert each record into student table

for ($i = 0; $i < count($rolls); $i++) {

$roll = mysqli_real_escape_string($conn, $rolls[$i]);

$name = mysqli_real_escape_string($conn, $names[$i]);

$total = mysqli_real_escape_string($conn, $totals[$i]);

$sql = "INSERT INTO student (Roll, Name, Total) VALUES ('$roll', '$name', '$total')";

if (mysqli_query($conn, $sql)) {

echo "Record " . ($i+1) . " inserted successfully.<br>";

} else {

echo "Error inserting record " . ($i+1) . ": " . mysqli_error($conn) . "<br>";

}
mysqli_close($conn);

?>

6 Write the AJAX, JavaScript, PHP and HTML Code to fetch the records from the above-mentioned table (with
other description) and display and records using a <Table> element.

Sure! Below is a complete working example using AJAX + JavaScript + PHP + HTML to fetch and display
all records from the student table (Roll, Name, Total) using a <table>.

✅ 1. HTML + JavaScript + AJAX (fetch_students.html)


<!DOCTYPE html>

<html>

<head>

<title>Fetch Student Records</title>

<script>

function fetchStudents() {

var xhr = new XMLHttpRequest();

xhr.open("GET", "fetch_students.php", true);

xhr.onload = function () {

if (this.status == 200) {

document.getElementById("studentTable").innerHTML = this.responseText;

};

xhr.send();

</script>

</head>

<body>

<h2>Student Records</h2>

<button onclick="fetchStudents()">Load Student Data</button>


<br><br>

<div id="studentTable">

<!-- Table will be inserted here -->

</div>

</body>

</html>

✅ 2. PHP Backend (fetch_students.php)


<?php

// Database credentials

$server = "localhost";

$username = "tabulator";

$password = "sysadmin";

$database = "BCA_PU";

// Create connection

$conn = mysqli_connect($server, $username, $password, $database);

// Check connection

if (!$conn) {

die("Connection failed: " . mysqli_connect_error());

// Fetch records

$sql = "SELECT Roll, Name, Total FROM student";

$result = mysqli_query($conn, $sql);

// Generate HTML Table


if (mysqli_num_rows($result) > 0) {

echo "<table border='1' cellpadding='10'>";

echo "<tr><th>Roll</th><th>Name</th><th>Total</th></tr>";

while ($row = mysqli_fetch_assoc($result)) {

echo "<tr>";

echo "<td>" . $row['Roll'] . "</td>";

echo "<td>" . $row['Name'] . "</td>";

echo "<td>" . $row['Total'] . "</td>";

echo "</tr>";

echo "</table>";

} else {

echo "No records found.";

mysqli_close($conn);

?>

You might also like