Practical File
For
CSIT248 - Advance Web Technology
Submitted to:
Dr. Reshu Agrawal
By:
PARAS BANSAL
Enrolment No. A1004823212
BCA - D
1. Design a web page to develop a student Registration Form using HTML.
INPUT:
OUTPUT:
2. Design a web page to introduce yourself
INPUT:
OUTPUT:
3. Design a web page to display timetable of current semester
INPUT:
OUTPUT:
4. Write a program to show ordered, unordered and description list.
INPUT:
OUTPUT:
5. Design a webpage to show the
scrolling text using marquee element
using HTML.
INPUT:
OUTPUT:
6. Use <img> tag to embed an image in a web page. Also set its width
and height.
INPUT:
OUTPUT:
7. Write a program to show front level validation in a Registration Form.
INPUT:
OUTPUT:
8. Create a HTML form with the use of Cascading Style Sheets.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Styled Registration Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 350px;
text-align: center;
}
h2 {
color: #333;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
label {
font-weight: bold;
margin-top: 10px;
}
input {
width: 90%;
padding: 10px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
width: 100%;
padding: 10px;
background: #28a745;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 10px;
}
button:hover {
background: #218838;
}
</style>
</head>
<body>
<div class="container">
<h2>Registration Form</h2>
<form name="regForm" onsubmit="return validateForm()">
<label for="name">Full Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<button type="submit">Register</button>
</form>
</div>
</body>
</html>
OUTPUT:
9. Create a catalog for shop which sells computer peripherals using html
tables.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Computer Peripherals Catalog</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 80%;
text-align: center;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 10px;
text-align: center;
}
th {
background-color: #28a745;
color: white;
}
</style>
</head>
<body>
<div class="container">
<h2>Computer Peripherals Catalog</h2>
<table>
<tr>
<th>Product</th>
<th>Image</th>
<th>Price</th>
<th>Description</th>
</tr>
<tr>
<td>Keyboard</td>
<td><img src="[Link]" alt="Keyboard"
width="100"></td>
<td>$30</td>
<td>Mechanical keyboard with RGB lighting.</td>
</tr>
<tr>
<td>Mouse</td>
<td><img src="[Link]" alt="Mouse" width="100"></td>
<td>$20</td>
<td>Wireless optical mouse with high precision.</td>
</tr>
<tr>
<td>Monitor</td>
<td><img src="[Link]" alt="Monitor"
width="100"></td>
<td>$150</td>
<td>24-inch Full HD LED monitor.</td>
</tr>
<tr>
<td>Printer</td>
<td><img src="[Link]" alt="Printer" width="100"></td>
<td>$100</td>
<td>All-in-one wireless printer.</td>
</tr>
<tr>
<td>Headset</td>
<td><img src="[Link]" alt="Headset"
width="100"></td>
<td>$50</td>
<td>Noise-canceling gaming headset.</td>
</tr>
</table>
</div>
</body>
</html>
OUTPUT:
10. Design a web page of your home town with an attractive
background color, text color, an image, font face etc. (Use inline CSS
for formatting).
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>My Hometown</title>
</head>
<body style="font-family: Arial, sans-serif; background-color: #f0f8ff; text-
align: center; color: #333;">
<h1 style="color: #2c3e50;">Welcome to My Hometown</h1>
<img src="[Link]" alt="Hometown View" width="600"
style="border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);">
<p style="font-size: 18px; line-height: 1.6; padding: 20px;">My
hometown is a beautiful place filled with rich culture, scenic landscapes, and
warm-hearted people. It is known for its historic sites, delicious local
cuisine, and vibrant festivals.</p>
<p style="font-size: 18px;">Come visit and explore the charm of my
hometown!</p>
</body>
</html>
OUTPUT:
11. Create a XML document of 10 student of SEM IV IT. Add their
Enrollment No., marks obtained in 5 subject, total marks and
percentage.
INPUT:
<?xml version="1.0" encoding="UTF-8"?>
<students>
<student>
<enrollmentNo>IT202401</enrollmentNo>
<marks>
<subject1>85</subject1>
<subject2>78</subject2>
<subject3>92</subject3>
<subject4>88</subject4>
<subject5>90</subject5>
</marks>
<totalMarks>433</totalMarks>
<percentage>86.6</percentage>
</student>
<student>
<enrollmentNo>IT202402</enrollmentNo>
<marks>
<subject1>75</subject1>
<subject2>80</subject2>
<subject3>70</subject3>
<subject4>85</subject4>
<subject5>79</subject5>
</marks>
<totalMarks>389</totalMarks>
<percentage>77.8</percentage>
</student>
<student>
<enrollmentNo>IT202403</enrollmentNo>
<marks>
<subject1>90</subject1>
<subject2>85</subject2>
<subject3>88</subject3>
<subject4>92</subject4>
<subject5>95</subject5>
</marks>
<totalMarks>450</totalMarks>
<percentage>90.0</percentage>
</student>
<student>
<enrollmentNo>IT202404</enrollmentNo>
<marks>
<subject1>80</subject1>
<subject2>70</subject2>
<subject3>75</subject3>
<subject4>78</subject4>
<subject5>82</subject5>
</marks>
<totalMarks>385</totalMarks>
<percentage>77.0</percentage>
</student>
<student>
<enrollmentNo>IT202405</enrollmentNo>
<marks>
<subject1>88</subject1>
<subject2>82</subject2>
<subject3>90</subject3>
<subject4>85</subject4>
<subject5>87</subject5>
</marks>
<totalMarks>432</totalMarks>
<percentage>86.4</percentage>
</student>
<student>
<enrollmentNo>IT202406</enrollmentNo>
<marks>
<subject1>72</subject1>
<subject2>78</subject2>
<subject3>74</subject3>
<subject4>76</subject4>
<subject5>80</subject5>
</marks>
<totalMarks>380</totalMarks>
<percentage>76.0</percentage>
</student>
<student>
<enrollmentNo>IT202407</enrollmentNo>
<marks>
<subject1>95</subject1>
<subject2>92</subject2>
<subject3>98</subject3>
<subject4>94</subject4>
<subject5>96</subject5>
</marks>
<totalMarks>475</totalMarks>
<percentage>95.0</percentage>
</student>
<student>
<enrollmentNo>IT202408</enrollmentNo>
<marks>
<subject1>60</subject1>
<subject2>65</subject2>
<subject3>70</subject3>
<subject4>68</subject4>
<subject5>72</subject5>
</marks>
<totalMarks>335</totalMarks>
<percentage>67.0</percentage>
</student>
<student>
<enrollmentNo>IT202409</enrollmentNo>
<marks>
<subject1>85</subject1>
<subject2>88</subject2>
<subject3>82</subject3>
<subject4>90</subject4>
<subject5>87</subject5>
</marks>
<totalMarks>432</totalMarks>
<percentage>86.4</percentage>
</student>
<student>
<enrollmentNo>IT202410</enrollmentNo>
<marks>
<subject1>78</subject1>
<subject2>80</subject2>
<subject3>85</subject3>
<subject4>83</subject4>
<subject5>88</subject5>
</marks>
<totalMarks>414</totalMarks>
<percentage>82.8</percentage>
</student>
</students>
12. Design a web page for Login form and perform validation using
Java script.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Login Form</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
width: 300px;
text-align: center;
}
h2 {
color: #333;
}
form {
display: flex;
flex-direction: column;
}
label {
font-weight: bold;
margin-top: 10px;
text-align: left;
}
input {
width: 100%;
padding: 10px;
margin: 8px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
width: 100%;
padding: 10px;
background: #28a745;
color: #fff;
border: none;
border-radius: 4px;
cursor: pointer;
margin-top: 10px;
}
button:hover {
background: #218838;
}
.error {
color: red;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h2>Login Form</h2>
<form onsubmit="return validateLogin()">
<label for="username">Username:</label>
<input type="text" id="username" name="username">
<span id="userError" class="error"></span>
<label for="password">Password:</label>
<input type="password" id="password" name="password">
<span id="passError" class="error"></span>
<button type="submit">Login</button>
</form>
</div>
<script>
function validateLogin() {
let username = [Link]("username").value;
let password = [Link]("password").value;
let userError = [Link]("userError");
let passError = [Link]("passError");
let isValid = true;
[Link] = "";
[Link] = "";
if ([Link]() === "") {
[Link] = "Username is required";
isValid = false;
}
if ([Link]() === "") {
[Link] = "Password is required";
isValid = false;
} else if ([Link] < 6) {
[Link] = "Password must be at least 6
characters";
isValid = false;
}
return isValid;
}
</script>
</body>
</html>
OUTPUT:
13. Design a web page to calculate the factorial, reverse, sum of
digits of a number and check whether it is odd or even.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Number Operations</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
input {
width: 80%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #218838;
}
.result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h2>Number Operations</h2>
<input type="number" id="number" placeholder="Enter a
number">
<button onclick="calculate()">Calculate</button>
<div class="result" id="result"></div>
</div>
<script>
function calculate() {
let num = [Link]("number").value;
let resultDiv = [Link]("result");
if (num === "") {
[Link] = "Please enter a number";
return;
}
num = parseInt(num);
let factorial = 1;
for (let i = 1; i <= num; i++) {
factorial *= i;
}
let reverse = parseInt([Link]().split('').reverse().join(''));
let sumOfDigits = [Link]().split('').reduce((sum, digit) =>
sum + parseInt(digit), 0);
let isEven = num % 2 === 0 ? "Even" : "Odd";
[Link] = `
Factorial: ${factorial} <br>
Reverse: ${reverse} <br>
Sum of Digits: ${sumOfDigits} <br>
Number is: ${isEven}
`;
}
</script>
</body>
</html>
OUTPUT:
14. Create a web page to calculate simple interest using Javascript.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Simple Interest Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
input {
width: 80%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #218838;
}
.result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h2>Simple Interest Calculator</h2>
<input type="number" id="principal" placeholder="Enter Principal
Amount">
<input type="number" id="rate" placeholder="Enter Interest Rate
(in %)">
<input type="number" id="time" placeholder="Enter Time (in
years)">
<button onclick="calculateSI()">Calculate</button>
<div class="result" id="result"></div>
</div>
<script>
function calculateSI() {
let principal = [Link]("principal").value;
let rate = [Link]("rate").value;
let time = [Link]("time").value;
let resultDiv = [Link]("result");
if (principal === "" || rate === "" || time === "") {
[Link] = "Please enter all values";
return;
}
principal = parseFloat(principal);
rate = parseFloat(rate);
time = parseFloat(time);
let simpleInterest = (principal * rate * time) / 100;
[Link] = `Simple Interest: $
{[Link](2)}`;
}
</script>
</body>
</html>
OUTPUT:
15. Create a web page to calculate gross salary using Java script.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Gross Salary Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
input {
width: 80%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
padding: 10px 20px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background: #218838;
}
.result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h2>Gross Salary Calculator</h2>
<input type="number" id="basicSalary" placeholder="Enter Basic
Salary">
<input type="number" id="hra" placeholder="Enter HRA
Amount">
<input type="number" id="da" placeholder="Enter DA Amount">
<input type="number" id="otherAllowances" placeholder="Enter
Other Allowances">
<button onclick="calculateGrossSalary()">Calculate</button>
<div class="result" id="result"></div>
</div>
<script>
function calculateGrossSalary() {
let basicSalary =
[Link]("basicSalary").value;
let hra = [Link]("hra").value;
let da = [Link]("da").value;
let otherAllowances =
[Link]("otherAllowances").value;
let resultDiv = [Link]("result");
if (basicSalary === "" || hra === "" || da === "" ||
otherAllowances === "") {
[Link] = "Please enter all values";
return;
}
basicSalary = parseFloat(basicSalary);
hra = parseFloat(hra);
da = parseFloat(da);
otherAllowances = parseFloat(otherAllowances);
let grossSalary = basicSalary + hra + da + otherAllowances;
[Link] = `Gross Salary: $
{[Link](2)}`;
}
</script>
</body>
</html>
OUTPUT:
16. Write a Java script program to show the use of onmouseover
event and onmouseout event.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Mouseover and Mouseout Event</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
flex-direction: column;
}
.box {
width: 200px;
height: 100px;
background-color: #007bff;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-size: 18px;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s;
}
</style>
</head>
<body>
<h2>Mouseover and Mouseout Event</h2>
<div class="box" onmouseover="changeColor(this)"
onmouseout="resetColor(this)">
Hover over me!
</div>
<script>
function changeColor(element) {
[Link] = "#28a745";
[Link] = "Mouse Over!";
}
function resetColor(element) {
[Link] = "#007bff";
[Link] = "Hover over me!";
}
</script>
</body>
</html>
OUTPUT:
17. Create an HTML page in which IFrames will be used as the target
frame for a link. Also set size and color of the IFrame borders.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>IFrame Target Example</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
iframe {
width: 600px;
height: 400px;
border: 4px solid #007bff;
border-radius: 8px;
}
.links {
margin-bottom: 10px;
}
a{
margin: 10px;
text-decoration: none;
font-size: 18px;
color: #007bff;
font-weight: bold;
}
a:hover {
color: #0056b3;
}
</style>
</head>
<body>
<h2>IFrame Target Example</h2>
<div class="links">
<a href="[Link]
target="iframeTarget">Example</a>
<a href="[Link]
target="iframeTarget">W3Schools</a>
<a href="[Link]
target="iframeTarget">Wikipedia</a>
</div>
<iframe name="iframeTarget"
src="[Link]
</body>
</html>
OUTPUT:
18. Design a webpage using Pseudo Classes.
INPUT:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>Pseudo Classes Example</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
}
h2 {
color: #333;
}
a{
text-decoration: none;
font-size: 18px;
color: #007bff;
font-weight: bold;
}
a:hover {
color: #ff6600;
}
a:active {
color: #ff0000;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #007bff;
color: white;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s;
}
.button:hover {
background-color: #0056b3;
}
.button:active {
background-color: #ff6600;
}
input:focus {
border: 2px solid #ff6600;
outline: none;
}
p:first-child {
font-weight: bold;
color: #28a745;
}
</style>
</head>
<body>
<h2>Pseudo Classes Example</h2>
<p>First paragraph - styled using <code>:first-child</code>.</p>
<p>Another paragraph - normal styling.</p>
<a href="#">Hover over this link</a>
<br><br>
<button class="button">Hover & Click Me</button>
<br><br>
<input type="text" placeholder="Focus on me!">
</body>
</html>
OUTPUT:
19. Write a Php Script to implement following MYSQL commands: a)
DELETE b) ORDER BY c) UPDATE.
INPUT:
<?php
$servername = "localhost";
$username = "root"; // Change if needed
$password = ""; // Change if needed
$dbname = "student_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// DELETE example: Remove a student with a specific ID
$deleteQuery = "DELETE FROM students WHERE id = 5";
if ($conn->query($deleteQuery) === TRUE) {
echo "Record deleted successfully.<br>";
} else {
echo "Error deleting record: " . $conn->error . "<br>";
}
// ORDER BY example: Retrieve students ordered by marks in
descending order
$orderQuery = "SELECT * FROM students ORDER BY marks DESC";
$result = $conn->query($orderQuery);
if ($result->num_rows > 0) {
echo "<h3>Students Ordered by Marks:</h3>";
while ($row = $result->fetch_assoc()) {
echo "ID: " . $row["id"] . " - Name: " . $row["name"] . " - Marks: " .
$row["marks"] . "<br>";
}
} else {
echo "No records found.<br>";
}
// UPDATE example: Increase marks by 5 for students scoring less than
50
$updateQuery = "UPDATE students SET marks = marks + 5 WHERE
marks < 50";
if ($conn->query($updateQuery) === TRUE) {
echo "Records updated successfully.<br>";
} else {
echo "Error updating records: " . $conn->error . "<br>";
}
$conn->close();
?>
OUTPUT:
20. Write a Php Script to add new record in CUSTOMER database.
INPUT:
<?php
$servername = "localhost";
$username = "root"; // Change if needed
$password = ""; // Change if needed
$dbname = "customer_db"; // Your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Customer details to be inserted
$customer_name = "John Doe";
$email = "johndoe@[Link]";
$phone = "1234567890";
$address = "123 Main St, New York, USA";
// Insert query
$sql = "INSERT INTO customers (name, email, phone, address) VALUES
('$customer_name', '$email', '$phone', '$address')";
if ($conn->query($sql) === TRUE) {
echo "New customer record added successfully!";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
OUTPUT:
21. Write a Php Script to implement function include () and require( ).
INPUT:
<!-- [Link] -->
<!DOCTYPE html>
<html>
<head>
<title>Include & Require Example</title>
</head>
<body>
<h2>Welcome to My Website</h2>
<hr>
<!-- [Link] -->
<hr>
<p>© 2025 MyWebsite. All rights reserved.</p>
</body>
</html>
<?php
// Using include() to add the header
include("[Link]");
echo "<p>This is the main content of the website.</p>";
// Using require() to add the footer
require("[Link]");
?>
OUTPUT:
22. Write php Script to demonstrate array, string and numeric
function.
INPUT:
<?php
echo "<h2>Array, String, and Numeric Function Demonstration</h2>";
// ARRAY FUNCTIONS
echo "<h3>Array Functions</h3>";
$fruits = array("Apple", "Banana", "Orange", "Grapes");
echo "Original Array: ";
print_r($fruits);
echo "<br>Array Count: " . count($fruits);
array_push($fruits, "Mango"); // Add new element
echo "<br>After Adding Mango: ";
print_r($fruits);
array_pop($fruits); // Remove last element
echo "<br>After Removing Last Element: ";
print_r($fruits);
sort($fruits); // Sorting array
echo "<br>Sorted Array: ";
print_r($fruits);
echo "<br>";
// STRING FUNCTIONS
echo "<h3>String Functions</h3>";
$str = "Hello World!";
echo "Original String: $str";
echo "<br>String Length: " . strlen($str);
echo "<br>Uppercase: " . strtoupper($str);
echo "<br>Lowercase: " . strtolower($str);
echo "<br>Word Count: " . str_word_count($str);
echo "<br>Reverse String: " . strrev($str);
echo "<br>Replace 'World' with 'PHP': " . str_replace("World", "PHP",
$str);
echo "<br>";
// NUMERIC FUNCTIONS
echo "<h3>Numeric Functions</h3>";
$num = -25.7;
echo "Original Number: $num";
echo "<br>Absolute Value: " . abs($num);
echo "<br>Square Root: " . sqrt(49);
echo "<br>Rounded Value: " . round($num);
echo "<br>Random Number (1-100): " . rand(1, 100);
echo "<br>Maximum of (10, 20, 30): " . max(10, 20, 30);
echo "<br>Minimum of (10, 20, 30): " . min(10, 20, 30);
?>
OUTPUT:
23. Write a PHP script to create Employee table and insert 3 records
into it using MYSQL. Employee table should contain 3 fields i.e
EmployeeID, EmployeeName and EmployeeDesignation.
INPUT:
<?php
$servername = "localhost";
$username = "root"; // Change if needed
$password = ""; // Change if needed
$dbname = "company_db"; // Your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create Employee Table
$createTableQuery = "CREATE TABLE IF NOT EXISTS Employee (
EmployeeID INT AUTO_INCREMENT PRIMARY KEY,
EmployeeName VARCHAR(100) NOT NULL,
EmployeeDesignation VARCHAR(100) NOT NULL
)";
if ($conn->query($createTableQuery) === TRUE) {
echo "Table 'Employee' created successfully.<br>";
} else {
echo "Error creating table: " . $conn->error . "<br>";
}
// Insert 3 Employee Records
$insertQuery = "INSERT INTO Employee (EmployeeName,
EmployeeDesignation) VALUES
('Alice Johnson', 'Software Engineer'),
('Bob Smith', 'Project Manager'),
('Charlie Brown', 'System Analyst')";
if ($conn->query($insertQuery) === TRUE) {
echo "3 records inserted successfully.<br>";
} else {
echo "Error inserting records: " . $conn->error . "<br>";
}
// Close connection
$conn->close();
?>
OUTPUT: