CC 13 2023
CC 13 2023
(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).
Data visibility Data sent in URL (visible) Data sent in body (hidden)
✅ 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>
2 Write short notes on the following : Head element, Types of color codes used in CSS, XML, History of
Internet, its advantages and disadvantage.
● It may include:
✅ Example:
<head>
<title>My Web Page</title>
<link rel="stylesheet" href="style.css">
</head>
6. HSLA
● Unlike HTML, XML does not have predefined tags; you define your own.
✅ Example:
<student>
<name>John</name>
<age>20</age>
</student>
🌐 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.
Disadvantages:
● Privacy issues
3 Explain any 5 important string functions in PHP. Write a common PHP code demonstrating the use of all
these function.
strlen("Hello"); // Outputs: 5
2. strrev()
● Reverses a string.
strrev("Hello"); // Outputs: "olleH"
3. strtolower()
4. strtoupper()
5. strpos()
// 3. Convert to lowercase
// 4. Convert to uppercase
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.
● Attribute:
○ type: Specifies the type of list marker (1 = numbers, A = uppercase letters, a = lowercase
letters).
Example:
<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:
Example:
<ul type="square">
<li>Milk</li>
<li>Eggs</li>
<li>Bread</li>
</ul>
● Attributes:
Example:
<dl>
<dt>Coffee</dt>
<dt>Tea</dt>
</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>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ol>
<ul type="square">
<li>Milk</li>
<li>Eggs</li>
<li>Bread</li>
</ul>
<dl>
<dt>Coffee</dt>
<dt>Tea</dt>
</dl>
<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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reverse a Number</title>
</head>
<body>
</form>
</body>
</html>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$number = $_POST['number'];
if (is_numeric($number)) {
$reversed = strrev($number);
} else {
}
}
?>
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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form id="numberForm">
</form>
<h3 id="result"></h3>
<script>
function findGreater() {
num1 = parseFloat(num1);
num2 = parseFloat(num2);
if (isNaN(num1) || isNaN(num2)) {
} else {
} else {
</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.
---
In HTML, the `<table>` element is used to create a table structure, and it contains several child elements to
define the table's structure.
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:
---
MySQL uses SQL (Structured Query Language) to interact with databases. Here are three essential SQL
commands:
#### 1. **SELECT**:
```
- This retrieves all columns (`*`) from the `employees` table where the `department` is 'Sales'.
```sql
```
- This inserts a new row into the `employees` table with values for `name`, `department`, and `salary`.
#### 3. **UPDATE**:
```sql
UPDATE employees
```
- This updates the `salary` of the employee with the name 'John Doe' to 55000.
---
CSS selectors are patterns used to select and style HTML elements. Here are some important CSS selectors:
#### 1. **Universal Selector (`*`)**:
```css
*{
color: red;
```
```css
#header {
background-color: blue;
```
```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]`)**:
```css
input[type="text"] {
```
```css
a:hover {
color: red;
```
- This changes the link color to red when the user hovers over it.
---
PHP has several **global constants** that are built into the language. Here are some important ones:
#### 1. **`PHP_VERSION`**:
```
#### 2. **`PHP_OS`**:
```php
```
#### 3. **`PHP_EOL`**:
```php
```
- Ensures the correct line-ending characters are used across different platforms (Windows uses `\r\n`,
Unix-based uses `\n`).
#### 4. **`NULL`**:
```php
$var = NULL;
if (is_null($var)) {
}
```
```php
if (TRUE) {
} else {
```
- 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.
The strlen() function is used to get the length of a string (i.e., the number of characters it contains).
Example:
● Explanation: The string "Hello, World!" has 13 characters, so strlen() returns 13.
Example:
$number = 3.14159;
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.
Example:
● Explanation: The rand(1, 100) generates a random number between 1 and 100 (inclusive).
Example:
} else {
● 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.
Example:
$variable = "Hello";
if (isset($variable)) {
} else {
● Explanation: Since $variable is set, isset() returns true, and the message "Variable is set." is
displayed.
The array_push() function is used to add one or more elements to the end of an array.
Example:
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.
<?php
// Adding an element
?>
● 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.
<?php
$person = [
];
$person["occupation"] = "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
$students = [
];
$students[] = ["name" => "Emma", "age" => 23, "grade" => "C"];
?>
● 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.
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.
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.
👉 Visit: www.w3.org
✅ Different Versions of CSS
Version Description
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).
3. Saves time – Make one change and affect the entire site.
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
<style>
p{
color: blue;
</style>
</head>
</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)
🔹 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.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<fieldset>
</fieldset>
<br>
<?php } ?>
</form>
</body>
</html>
// Database credentials
$server = "localhost";
$username = "tabulator";
$password = "sysadmin";
$database = "BCA_PU";
// Create connection
// Check connection
if (!$conn) {
$rolls = $_POST['roll'];
$names = $_POST['name'];
$totals = $_POST['total'];
$sql = "INSERT INTO student (Roll, Name, Total) VALUES ('$roll', '$name', '$total')";
if (mysqli_query($conn, $sql)) {
} 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>.
<html>
<head>
<script>
function fetchStudents() {
xhr.onload = function () {
if (this.status == 200) {
document.getElementById("studentTable").innerHTML = this.responseText;
};
xhr.send();
</script>
</head>
<body>
<h2>Student Records</h2>
<div id="studentTable">
</div>
</body>
</html>
// Database credentials
$server = "localhost";
$username = "tabulator";
$password = "sysadmin";
$database = "BCA_PU";
// Create connection
// Check connection
if (!$conn) {
// Fetch records
echo "<tr><th>Roll</th><th>Name</th><th>Total</th></tr>";
echo "<tr>";
echo "</tr>";
echo "</table>";
} else {
mysqli_close($conn);
?>