wt_8_to_10
wt_8_to_10
$counterFile = "counter.txt";
if (!file_exists($counterFile)) {
file_put_contents($counterFile, "0");
$currentCount = file_get_contents($counterFile);
$newCount = $currentCount + 1;
file_put_contents($counterFile, $newCount);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
text-align: center;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
background-color: #f4f4f9;
color: #333;
.container {
background: #fff;
padding: 20px;
border-radius: 8px;
margin: 0 auto;
width: 60%;
h1 {
font-size: 2.5em;
margin: 0;
p{
font-size: 1.2em;
color: #555;
</style>
</head>
<body>
<div class="container">
</body>
</html>
8B . Develop a PHP program (with HTML/CSS) to sort the student records which are
stored in the database using selection sort.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "students";
if ($conn->connect_error) {
$result = $conn->query($sql);
$students = [];
if ($result->num_rows > 0) {
$students[] = $row;
$n = count($arr);
$minIndex = $i;
$minIndex = $j;
$temp = $arr[$i];
$arr[$i] = $arr[$minIndex];
$arr[$minIndex] = $temp;
selectionSort($students, 'name');
?>
<!DOCTYPE html>
<head>
<style>
body {
background-color: #f0f2f5;
color: #333;
margin: 0;
padding: 20px;
}
h2 {
text-align: center;
color: #4A90E2;
margin-bottom: 20px;
table {
width: 100%;
border-collapse: collapse;
background-color: #fff;
border-radius: 10px;
overflow: hidden;
margin: 0 auto;
th,
td {
text-align: left;
th {
background-color: #4A90E2;
color: white;
text-transform: uppercase;
letter-spacing: 0.03em;
}
tr {
tr:hover {
background-color: #f1f1f1;
td {
font-size: 0.9em;
color: #555;
table,
th,
td {
display: block;
width: 100%;
th,
td {
box-sizing: border-box;
tr {
margin-bottom: 15px;
display: block;
th {
position: absolute;
top: -9999px;
left: -9999px;
td {
border: none;
position: relative;
padding-left: 50%;
text-align: right;
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>USN</th>
<th>Branch</th>
<th>Email</th>
<th>Address</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
</body>
</html>
9 . Develop jQuery script (with HTML/CSS) for:
a) Appends the content at the end of the existing paragraph and list.
b) Change the state of the element with CSS style using animate() method.
c) Change the color of any div that is animated.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jQuery Demo</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
margin: 20px;
background-color: #f4f4f4;
.container {
max-width: 600px;
margin: auto;
padding: 20px;
background: white;
border-radius: 5px;
.box {
width: 100px;
height: 100px;
background-color: #3498db;
margin: 20px 0;
button {
background-color: #2ecc71;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 10px;
button:hover {
background-color: #27ae60;
</style>
</head>
<body>
<div class="container">
<h1>jQuery Demo</h1>
<ul id="existingList">
</ul>
</div>
<script>
$(document).ready(function() {
// a. Append content
$("#appendButton").click(function() {
$("#existingList").append("<li>Appended item</li>");
});
// b. Animate element
$("#animateButton").click(function() {
$("#animateBox").animate({
width: "200px",
height: "200px",
opacity: 0.5
}, 1000);
});
$("#colorAnimateButton").click(function() {
$("#colorBox").animate({
width: "200px",
height: "200px"
}, {
duration: 1000,
});
});
});
</script>
</body>
</html>
10. Develop a JavaScript program with Ajax (with HTML/CSS) for:
a) Use ajax() method (without Jquery) to add the text content from the text file by
sending ajax request.
b) Use ajax() method (with Jquery) to add the text content from the text file by
sending ajax request.
c) Illustrate the use of getJSON() method in jQuery.
d) Illustrate the use of parseJSON() method to display JSON values.
<!DOCTYPE html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
background-color: #f4f4f9;
h1 {
text-align: center;
color: #333;
padding: 20px 0;
#content {
flex-direction: column;
display: flex;
max-width: 600px;
border-radius: 8px;
background-color: #fff;
button {
display: inline-block;
margin: 12px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: #fff;
font-size: 16px;
cursor: pointer;
button:hover {
button:focus {
#output {
display: none;
margin-top: 20px;
padding: 10px;
border-radius: 5px;
white-space: pre-wrap;
max-height: 300px;
overflow-y: auto;
#output.plain-ajax {
background-color: #f0f8ff;
#output.jquery-ajax {
background-color: #f5fffa;
#output.jquery-json {
background-color: #fffaf0;
#output.parse-json {
background-color: #fff0f5;
</style>
</head>
<body>
<h1>AJAX Examples</h1>
<div id="content">
<div id="output"></div>
</div>
<script>
function showOutput(className) {
const output = document.getElementById('output');
output.className = className;
output.style.display = 'block';
document.getElementById('plain-ajax-btn').addEventListener('click', function () {
xhr.onload = function () {
document.getElementById('output').innerText = xhr.responseText;
} else {
showOutput('plain-ajax');
};
xhr.send();
});
$('#jquery-ajax-btn').on('click', function () {
$.ajax({
url: 'textfile.txt',
method: 'GET',
$('#output').text(data);
},
error: function () {
}).always(function () {
showOutput('jquery-ajax');
});
});
$('#jquery-json-btn').on('click', function () {
$.getJSON('data.json')
.done(function (data) {
})
.fail(function () {
})
.always(function () {
showOutput('jquery-json');
});
});$('#parse-json-btn').on('click', function () {
$.get('data.json')
.done(function (data) {
try {
let jsonData;
jsonData = JSON.parse(data);
} else {
jsonData = data;
} catch (e) {
})
.fail(function () {
})
.always(function () {
showOutput('parse-json');
});
});
</script>
</body>
</html>