Web Technology 2074-2080
Web Technology 2074-2080
Web Technology 2074-2080
Group “A”
• Which tag do we use to define the options present in the drop-down selection lists?
• a. <list>
• b. <option>
• c. <dropdown>
• d. <select>
b. <option>
• Which of the following is the correct syntax to link an external stylesheet in the HTML file?
• a. sysinfo()
• b. phpinfo()
• c. info()
• d. php_info()
b. phpinfo()
• Which of the methods are used to manage result sets using both associative and indexed
arrays?
• Which of the following is the method that web servers use to host more than one domain name
on the same computer and IP address?
• a. WebHost
• b. Domain Name
• c. Virtual hosting
• d. MultiHosting
c. Virtual hosting
• What is the default value of max_execution_time directive? This directive specifies how
many seconds a script can execute before being terminated.
• a. 10
• b. 20
• c. 30
• d. 40
c. 30
d. ALTER
Group ”B”
HTML Lists: HTML lists are used to group a set of related items in a well-structured and
semantic way. There are three main types of lists in HTML: ordered lists, unordered lists, and
definition lists.
1. Ordered List (<ol>): An ordered list is used when the order of the items matters. Each
item in the list is numbered.
Example:
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
2. Unordered List (<ul>): An unordered list is used when the order of the items does not
matter. Each item in the list is marked with a bullet point.
Example:
<ul>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ul>
3. Definition List (<dl>): A definition list is used for items that come in pairs, like terms
and definitions.
Example:
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
<dt>JavaScript</dt>
<dd>A programming language for the web</dd>
</dl>
2. Define Cascading Style Sheet. What are the advantages of using CSS in web
development?
Cascading Style Sheet (CSS): CSS is a language used to describe the presentation of a
document written in HTML or XML. It controls the layout of multiple web pages all at once and
is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
OR
What do you mean by CSS layout? Explain different types of CSS layouts with examples.
CSS Layout: CSS layout refers to the arrangement of elements on a web page using CSS. It
determines how elements are displayed and positioned in relation to each other.
1. Normal Flow:
o The default layout where elements are displayed one after the other in the order
they appear in the HTML.
<div>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</div>
2. Float Layout:
o Uses the float property to push elements to the left or right, allowing other
elements to wrap around them.
<div style="float: left; width: 50%;">
<p>This is a floated element.</p>
</div>
<div style="float: right; width: 50%;">
<p>This is another floated element.</p>
</div>
3. Flexbox Layout:
o A layout model that allows you to design a flexible and responsive layout
structure without using float or positioning.
<div style="display: flex;">
<div style="flex: 1;">Item 1</div>
<div style="flex: 1;">Item 2</div>
<div style="flex: 1;">Item 3</div>
</div>
4. Grid Layout:
o A two-dimensional layout system that allows you to create grid-based layouts
using rows and columns.
<div style="display: grid; grid-template-columns: auto auto
auto;">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
3. What are the features of JavaScript? Write a JavaScript code to find the factorial of a
user input number.
Features of JavaScript:
<script>
function calculateFactorial() {
var num =
parseInt(document.getElementById('number').value);
var factorial = 1;
document.getElementById('result').innerText =
"Factorial of " + num + " is " + factorial;
}
</script>
</body>
</html>
4. What is string in PHP? Explain any five string functions with syntax and examples.
String in PHP: A string in PHP is a sequence of characters. It can be any text inside quotes. You
can use single or double quotes to define a string.
1. strlen():
o Returns the length of a string.
o Syntax: strlen(string)
o Example:
$str = "Hello, World!";
echo strlen($str); // Output: 13
2. strpos():
o Finds the position of the first occurrence of a substring in a string.
o Syntax: strpos(haystack, needle)
o Example:
$str = "Hello, World!";
echo strpos($str, "World"); // Output: 7
3. str_replace():
o Replaces all occurrences of a search string with a replacement string.
o Syntax: str_replace(search, replace, subject)
o Example:
$str = "Hello, World!";
echo str_replace("World", "PHP", $str); // Output:
Hello, PHP!
4. substr():
o Returns a part of a string.
o Syntax: substr(string, start, length)
o Example:
$str = "Hello, World!";
echo substr($str, 7, 5); // Output: World
5. strtoupper():
o Converts a string to uppercase.
o Syntax: strtoupper(string)
o Example:
$str = "Hello, World!";
echo strtoupper($str); // Output: HELLO, WORLD!
OR
Define session. Explain how to register, unregister and delete session Variable in PHP with
example.
Session:
A session in PHP is a way to store information (in variables) to be used across multiple pages.
Unlike cookies, the information is not stored on the user's computer.
3. Deleting a Session:
<?php
session_start(); // Start the session
session_unset(); // Unset all session variables
session_destroy(); // Destroy the session
?>
5. Explain the use of $_GET and $_POST methods in form submitting with proper
example with their differences.
$_GET Method:
When the form is submitted, the URL will look like: process.php?name=John
$_POST Method:
• Purpose: Used to send data to the server in the body of the HTTP request.
• Security: More secure because data is not visible in the URL.
• Usage: Suitable for sensitive data, like passwords or personal information.
• Example:
<form action="process.php" method="post">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<button type="submit">Submit</button>
</form>
Differences:
• Visibility: $_GET appends form data to the URL, making it visible and bookmarkable.
$_POST does not modify the URL.
• Security: $_POST is more secure as it doesn't expose sensitive data in the URL.
• Data Size: $_GET has limits on the amount of data it can handle (URL length
limitations), while $_POST can handle larger amounts of data.
6. What is mysql_fetch_array()? Explain how to retrieve data from the MySQL database
using PHP.
mysql_fetch_array():
Example: Suppose you have a MySQL database students with a table student_info
containing fields id, name, and age. Here's how you can retrieve data using PHP:
1. Connecting to MySQL:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "students";
// Create connection
$conn = new mysqli($servername, $username, $password,
$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_array()) {
// Access data using both associative and numeric
indices
echo "ID: " . $row["id"]. " - Name: " .
$row["name"]. " - Age: " . $row["age"]. "<br>";
// Alternatively, you can use numeric indices:
$row[0], $row[1], etc.
}
} else {
echo "0 results";
}
$conn->close();
?>
Explanation:
This approach retrieves data from the MySQL database students, displaying student IDs,
names, and ages. Adjustments can be made based on specific table structures and query
requirements.
2079
<img> Tag: The <img> tag is used to embed images in an HTML page. It is an empty tag,
meaning it doesn't have a closing tag. It requires the src attribute, which contains the path to the
image, and the alt attribute, which provides alternative text for the image.
Example:
<img src="image.jpg" alt="A beautiful scenery">
<a> Tag: The <a> tag defines a hyperlink, which is used to link from one page to another. The
most important attribute of the <a> element is the href attribute, which indicates the link's
destination.
Example:
html
Copy code
<a href="https://www.example.com">Visit Example.com</a>
2. How is HTML different from CSS? Explain the ways for inserting CSS code into an
HTML file.
1. Inline CSS: Directly within an HTML element using the style attribute.
<p style="color:blue;">This is a blue paragraph.</p>
2. Internal CSS: Within a <style> tag inside the <head> section of an HTML
document.
<head>
<style>
p {
color: blue;
}
</style>
</head>
3. External CSS: Using an external CSS file linked to the HTML document.
<head>
<link rel="stylesheet" href="styles.css">
</head>
OR
What is media query? Explain how to create a responsive web page with example.
Media Query: A media query is a CSS technique used to apply styles based on the conditions
like screen size, resolution, and orientation. It helps in creating responsive web designs that look
good on various devices.
3. Create an HTML form for student information to enter marks in five subjects and write
a JavaScript code to find total, average, result, and grade.
HTML Form:
<!DOCTYPE html>
<html>
<head>
<title>Student Information Form</title>
</head>
<body>
<form id="studentForm">
<label for="subject1">Subject 1:</label>
<input type="number" id="subject1" name="subject1"><br>
<p id="results"></p>
<script>
function calculateResults() {
var subject1 =
parseFloat(document.getElementById('subject1').value);
var subject2 =
parseFloat(document.getElementById('subject2').value);
var subject3 =
parseFloat(document.getElementById('subject3').value);
var subject4 =
parseFloat(document.getElementById('subject4').value);
var subject5 =
parseFloat(document.getElementById('subject5').value);
document.getElementById('results').innerHTML =
"Total: " + total + "<br>Average: " + average + "<br>Result: " +
result + "<br>Grade: " + grade;
}
</script>
</body>
</html>
4. What are the advantages and disadvantages of using CSV file format? Explain how to
display data from a CSV file using PHP.
Advantages of CSV:
Disadvantages of CSV:
OR
Define array. Explain about the types of Arrays in PHP with examples.
Array: An array is a special variable that can hold multiple values at once.
• mysql_fetch_row(): Fetches one row of data from the result set as a numeric array.
$row = mysql_fetch_row($result);
echo $row[0]; // Accesses the first column of the fetched
row
• mysql_fetch_array(): Fetches one row of data from the result set as an associative
array, a numeric array, or both. It is more versatile.
$row = mysql_fetch_array($result);
echo $row['column_name']; // Accesses the data by column
name
echo $row[0]; // Accesses the data by column index
6. How PHP and MySQL are related? Explain how to execute MySQL "insert and select"
query and fetch results stu_roll, stu_name, stu_address from database table
"students" using PHP.
PHP and MySQL Relationship:
Insert Query:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Insert query
$sql = "INSERT INTO students (stu_roll, stu_name, stu_address)
VALUES (1, 'John Doe', '123 Main St')";
$conn->close();
?>
Select Query:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Select query
$sql = "SELECT stu_roll, stu_name, stu_address FROM students";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "Roll: " . $row["stu_roll"]. " - Name: " .
$row["stu_name"]. " - Address: " . $row["stu_address"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
Group "A"
d. <a href="mailto:abc@xyz">
2. Which of the following is used to specify the superscript of text using CSS?
a. vertical-align: super
b. vertical-align: baseline
c. vertical-align: superscript
a. vertical-align: super
d. links to a URL
a. Function
b. File
c. Date
d. Window
d. Window
a. 3D file
b. Flat file
c. String file
d. Random file
b. Flat file
7. What is name of PHP "===" operator?
a. Equal
b. Identical
c. Identity
d. Safe Equal
b. Identical
a. strlen()
b. str_replace()
c. strpos()
d. strreverse()
d. strreverse()
9. Which method returns the error code generated from the execution of the last MySQL
function?
a. errno()
b. errnumber()
c. errorno()
d. errornumber()
a. errno()
10. Which of the following command is used to delete all rows and free up space from a
table?
a. TRUNCATE
b. DROP
c. DELETE
d. ALTER
a. TRUNCATE
2078
Group "A"
This tag defines a section in an HTML document:
(a) div
Which attribute can be added to many HTML elements to identify them as a member of a
specific group?
(a) id
Study the following steps and determine the correct order:
(b) 4, 2, 3, 5, 1
Open a connection to MySQL server
Execute the SQL query
Fetch the data from query
Select the database
Close the connection
Which HTML attribute is used to define inline styles?
(a) style
Which of the following is the correct syntax for adding a comment in CSS code?
(a) /* comment */
Which of the following variables takes precedence over the others if the names are the same?
(b) Local variable
In JavaScript, the === statement implies that:
(a) Both A and B are equal in value, and data types are also the same
PHP stands for:
(d) PHP Hypertext Preprocessor
Which one of the following sends input to a script via a URL?
(a) Get
Which one of the following functions is used to start a session?
(a) start_session()
1. What do you mean by responsive CSS? What are its advantages?
Responsive CSS refers to the use of CSS (Cascading Style Sheets) techniques to create web pages
that adapt to different screen sizes and devices. This ensures that the content is easily readable
and the layout is usable on any device, from desktop computers to tablets and smartphones.
Advantages:
Improved User Experience: Ensures a seamless experience across all devices, enhancing user
satisfaction.
Increased Mobile Traffic: With more people accessing the web via mobile devices, responsive
design can help capture and retain this audience.
Cost Effective: Reduces the need for separate mobile and desktop websites.
SEO Benefits: Google favors mobile-friendly websites in search rankings.
Easier Maintenance: One website to update, rather than multiple versions.
OR
What is sessions in PHP? How is it different from cookies?
Sessions in PHP are a way to store information (in variables) to be used across multiple pages.
Unlike cookies, the information is not stored on the user's computer. Sessions are used to
maintain state and user data across the site.
Differences between Sessions and Cookies:
Storage Location: Sessions store data on the server, while cookies store data on the client's
browser.
Security: Sessions are generally more secure as the data is stored on the server, reducing the
risk of user tampering.
Lifetime: Session data is temporary and typically expires when the user closes the browser,
while cookies can persist for a specified duration.
Data Size: Cookies have a size limit of around 4KB, whereas sessions can handle larger amounts
of data.
2. Write short notes on : AMP, Server side scripting language and Static website.
AMP (Accelerated Mobile Pages):
AMP is an open-source project designed to optimize web pages for mobile browsing by enabling
faster load times. It uses a stripped-down version of HTML and a limited set of JavaScript to
ensure high performance and speedy rendering on mobile devices.
Server Side Scripting Language:
A server-side scripting language is a programming language used to create dynamic web pages.
The script runs on the server rather than the user's browser. Examples include PHP, Python,
Ruby, and Node.js. These languages interact with databases, process form data, and generate
HTML content before sending it to the client's browser.
Static Website:
A static website consists of web pages with fixed content. Each page is an HTML file stored on a
server and sent to the user's browser as-is. Static websites do not require server-side processing
and are ideal for small websites with infrequent content changes. They are fast, secure, and
easy to host.
3. What do you mean by event handler in JavaScript? Write script to show it.
An event handler in JavaScript is a function that executes in response to a specific event
triggered by user interaction or browser actions (e.g., clicks, form submissions, page loads).
Example Script:
<!DOCTYPE html>
<html>
<head>
<title>Event Handler Example</title>
<script type="text/javascript">
function handleClick() {
alert('Button clicked!');
}
</script>
</head>
<body>
<button onclick="handleClick()">Click Me!</button>
</body>
</html>
4. Write about scope of variable in PHP. How can you pass value by reference in function?
Give example.
Scope of Variable in PHP:
The scope of a variable in PHP determines where it can be accessed or modified. The main
scopes are:
Local Scope: Variables declared within a function are only accessible within that function.
Global Scope: Variables declared outside any function are accessible globally, but not within
functions unless explicitly stated.
Static Scope: Static variables retain their value even after the function has exited.
Pass by Reference:
Passing by reference means passing the actual memory address of the variable, allowing the
function to modify the variable's value.
Example:
<?php
function addFive(&$number) {
$number += 5;
}
$value = 10;
addFive($value);
echo $value; // Outputs: 15
?>
5. Differentiate between GET and POST.
GET:
Data in URL: Appends data to the URL.
Size Limit: Limited by URL length (about 2048 characters).
Security: Less secure as data is exposed in the URL.
Caching: Data can be cached and bookmarked.
Usage: Suitable for non-sensitive data and query strings.
POST:
Data in Body: Sends data in the request body.
Size Limit: No significant size limit.
Security: More secure as data is not exposed in the URL.
Caching: Data is not cached or bookmarked.
Usage: Suitable for sensitive data and form submissions.
6. Write about any three database functions of PHP with syntax.
mysqli_connect():
Description: Establishes a new connection to the MySQL database.
Syntax:
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_query():
Description: Performs a query against the database.
Syntax:
$result = mysqli_query($conn, $sql);
mysqli_fetch_assoc():
Description: Fetches a result row as an associative array.
Syntax:
$row = mysqli_fetch_assoc($result);
OR
Write HTML code for:
mathematica
ABC
D E
F
HTML Code:
<!DOCTYPE html>
<html>
<head>
<title>Table Layout</title>
</head>
<body>
<table border="1">
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr>
<td>D</td>
<td colspan="2"></td>
<td>E</td>
</tr>
<tr>
<td>F</td>
</tr>
</table>
</body>
</html>
2077
Group "A"
Which of the following is an invalid HTML Tag?
a. <sup>
b. <sub>
c. <pow>
d. <BR>
Answer: c. <pow>
Which of the following attributes of the text box allows to limit the maximum character?
a. Size
b. Max
c. Maxlength
d. Maxlen
Answer: c. Maxlength
If we want to wrap a block of text around an image, which CSS property will we use?
a. Wrap
b. Float
c. Push
d. Clear
Answer: b. Float
What is the correct HTML for referring to an external style sheet?
a. <stylesheet>mystyle.css</stylesheet>
b. <link rel="stylesheet" type="text/css" href="mystyle.css">
c. <style src="mystyle.css" />
d. <link external="stylesheet" type="text/css" href="mystyle.css">
Answer: b. <link rel="stylesheet" type="text/css" href="mystyle.css">
When a user views a page containing a JavaScript program, which machine actually executes
the script?
a. Web Server
b. Application Server
c. Central Server
d. Client
Answer: d. Client
What is the output for the script:
<script type="text/javascript"> x=4+"4"; document.write(x); </script>
a. 44
b. 4
c. 8
d. Error
Answer: a. 44
What should we need to do to turn formal parameter names into default arguments?
a. Use assignment expression
b. Use Boolean expression
c. Use values rather than parameters
d. None of them
Answer: a. Use assignment expression
Which of the following methods sends input to a script via a URL?
a. Post
b. Get
c. Both
d. Send
Answer: b. Get
Which of the following array represents an array with strings as index?
a. Numeric Array
b. Ragged Array
c. Associative Array
d. String Array
Answer: c. Associative Array
Which one of the following statements can be used to select the database?
a. $mysqli=select_db('databasename')
b. mysqli=select_db('databasename')
c. mysqli->select_db('databasename')
d. $mysqli->select_db('databasename')
Answer: d. $mysqli->select_db('databasename')
Group "B"
Discuss different types of HTML tags used for creating lists with suitable examples.
Answer:
Ordered List (<ol>):
<ol>
<li>Item 1</li>
<li>Item 2</li>
</ol>
Unordered List (<ul>):
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
Description List (<dl>):
<dl>
<dt>Term 1</dt>
<dd>Description 1</dd>
</dl>
How can you use ID and class selectors? Explain with examples.
Answer:
ID Selector:
<style>
#myId {
color: blue;
}
</style>
<div id="myId">This is a div with an ID.</div>
Class Selector:
<style>
.myClass {
color: red;
}
</style>
<div class="myClass">This is a div with a class.</div>
<p class="myClass">This is a paragraph with the same class.</p>
Create a form containing fields User ID, password and Cell Number and validate the form such
that none of the fields are empty, password must be of at least six digits and cell number
should only contain digits using JavaScript.
Answer:
<form id="myForm">
User ID: <input type="text" id="userId"><br>
Password: <input type="password" id="password"><br>
Cell Number: <input type="text" id="cellNumber"><br>
<input type="button" value="Submit" onclick="validateForm()">
</form>
<script>
function validateForm() {
var userId = document.getElementById("userId").value;
var password = document.getElementById("password").value;
var cellNumber = document.getElementById("cellNumber").value;
if (userId === "" || password === "" || cellNumber === "") {
alert("All fields are required.");
return false;
}
if (password.length < 6) {
alert("Password must be at least 6 characters long.");
return false;
}
if (!/^\d+$/.test(cellNumber)) {
alert("Cell number must contain only digits.");
return false;
}
alert("Form is valid.");
}
</script>
Explain the concept of pass by value and pass by reference with suitable PHP code.
Answer:
// Pass by value
function incrementByValue($num) {
$num += 1;
}
$a = 5;
incrementByValue($a);
echo $a; // Outputs: 5
// Pass by reference
function incrementByReference(&$num) {
$num += 1;
}
$b = 5;
incrementByReference($b);
echo $b; // Outputs: 6
What is session? How sessions can be handled in PHP? Explain with example.
Answer:
// Start the session
session_start();
Answer:
// Connect to the database
$conn = mysqli_connect("localhost", "username", "password", "database");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Close connection
mysqli_close($conn);
2075
Group "B" - Short Answer Questions:
Describe the <Form> and <Table> tag with examples.
Form Tag:
<form action="/submit-form" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<input type="submit" value="Submit">
</form>
The <form> tag is used to create an HTML form for user input. The action attribute specifies
where to send the form data when a form is submitted. The method attribute specifies the
HTTP method (GET or POST) to be used when submitting the form.
Table Tag:
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
The <table> tag is used to create a table in HTML. <tr> defines a row in the table, <th> defines a
header cell, and <td> defines a standard data cell.
What is CSS? Describe the CSS layout techniques.
CSS (Cascading Style Sheets): CSS is a language used to describe the presentation of a document
written in HTML or XML. It controls the layout, colors, fonts, and overall visual appearance of
web pages.
CSS Layout Techniques:
Flexbox: A one-dimensional layout method for arranging items in rows or columns.
Grid: A two-dimensional layout system for designing web pages.
Float: An older method used to position elements to the left or right within a container.
Positioning: Using properties like absolute, relative, fixed, and sticky to control the placement of
elements.
Box Model: Understanding and manipulating the margin, border, padding, and content of
elements.
Write a JavaScript to validate the form at client side where student roll number, sex, and email
fields are not accepted in blank.
function validateForm() {
var rollNumber = document.forms["studentForm"]["rollNumber"].value;
var sex = document.forms["studentForm"]["sex"].value;
var email = document.forms["studentForm"]["email"].value;
Function: A function is a block of code that performs a specific task. It is defined once and can
be executed whenever called.
PHP Function Example:
function greet($name) {
return "Hello, " . $name;
}
echo greet("John");
This PHP function greet takes one argument $name and returns a greeting message.
What is MySQL? Describe the database connection methods in PHP.
MySQL: MySQL is an open-source relational database management system (RDBMS) based on
SQL (Structured Query Language).
PHP Database Connection Methods:
MySQLi (MySQL Improved):
$conn = new mysqli("localhost", "username", "password", "database");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
PDO (PHP Data Objects):
php
Copy code
try {
$conn = new PDO("mysql:host=localhost;dbname=database", "username", "password");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
Group "A" - Multiple Choice Questions:
What is the correct HTML for inserting an image?
c. <img src="image.gif" alt="My Image">
Which method is ideal for applying the same style to an entire website?
c. External CSS
Which of the following is correct to write "Hello World" on the web page?
c. document.write("Hello World")
Which of the following syntax is correct to refer an external script called "form Validation.js"?
a. <script href="form Validation.js">
What is the default extension for Apache configuration files?
a. .con
Which symbol is used to start with all variables in PHP?
a. $
Which of the following is an associative array containing session variables available to the
current script?
c. $_SESSION
Which one of the following statements can be used to select the database?
a. mysqli_select_db('databasename');
Which function is used to determine whether a file was uploaded?
a. is_file_uploaded()
Which statement is true for retrieving data from a FORM with an input named 'distance' that
is submitted using the "post" method?
a. $gap=$_POST['distance'];
2074
Group "B" - Short Answer Questions:
Describe the <IMG> and <A> tag with example.
IMG Tag:
<img src="image.jpg" alt="Sample Image">
The <img> tag is used to embed images in HTML. The src attribute specifies the path to the
image, and the alt attribute provides alternative text for the image.
A Tag:
<a href="https://www.example.com">Visit Example</a>
The <a> tag is used to create hyperlinks. The href attribute specifies the URL of the page the link
goes to.
What are the different types of CSS used in webpage designing? Explain.
Inline CSS:
<p style="color:blue;">This is a blue paragraph.</p>
CSS styles are applied directly within an HTML element using the style attribute.
Internal CSS:
<head>
<style>
p { color: blue; }
</style>
</head>
CSS rules are defined within the <style> tag inside the <head> section of the HTML document.
External CSS:
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
CSS rules are placed in an external file, which is linked to the HTML document using the <link>
tag.
Why do you use JavaScript? Write a JavaScript program to calculate multiplication and
division of two numbers provided by users.
<!DOCTYPE html>
<html>
<body>
<h2>JavaScript Multiplication and Division</h2>
<input type="number" id="num1" placeholder="Enter first number">
<input type="number" id="num2" placeholder="Enter second number">
<button onclick="calculate()">Calculate</button>
<p id="result"></p>
<script>
function calculate() {
var num1 = document.getElementById('num1').value;
var num2 = document.getElementById('num2').value;
var multiplication = num1 * num2;
var division = num1 / num2;
document.getElementById('result').innerHTML = "Multiplication: " + multiplication +
"<br>Division: " + division;
}
</script>
</body>
</html>
Explain about Web Server? What are the major issues in httpd.conf file to troubleshoot web
server in Apache?
Web Server: A web server is software that serves web pages to clients upon request. It
processes incoming network requests over HTTP and several other related protocols.
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
Database Connection Using PDO:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
Group "A" - Multiple Choice Questions:
How can you open a link in a new browser window?
c. <a href="url" target="_new">
What form of style rules are presented in CSS?
a. selector {property : value}
Which of the following is the correct way for writing JavaScript array?
b. var salaries = new Array(1:39438, 2:39839, 3:83729)
Which of the tag is an extension to HTML that can enclose any number of JavaScript
statements?
a. <SCRIPT>
Where is the default location for the main Apache configuration file (httpd.conf) on
Windows?
a. C:\Program Files\Apache Software Foundation\Apache2.2\conf
Which of the following will start a session in PHP?
a. session_start();
How do you get information from a form that is submitted using the "get" method?
a. $_GET[]
What is the best all-purpose way of comparing two strings?
a. Using the strcmp function
Which directive determines whether PHP scripts on the server can accept file uploads?
a. file_uploads
Which of the following parameter is not taken by mysql_connect() function in PHP?
c. User ID