Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

JAYA COLLEGE OF ARTS &SCIENCE

THIRUNINRAVUR – 602 024.

DEPARTMENT OF COMPUTER SCIENCE

PRACTICAL RECORD

Register No.

Certified to be the bonafide record of the work done by of

the course B. Sc. (Computer Science) I/II/III/IV/V/VI Semester in the Computer Science laboratory of

Jaya College of Arts & Science, Thiruninravur during the year 2021-2022.

Lecturer In-charge

Submitted for Practical Examination held on __________ at Jaya College ofArts & Science,

Thiruninravur.

Internal Examiner External Examiner


JAYA COLLEGE OF ARTS & SCIENCE
THIRUNINRAVUR

DEPARTMENT OF COMPUTER SCIENCE

PRACTICAL RECORD

NAME:..................................... REG NO:.....................................

COURSE:................................. SEMESTER:..............................

SUBJECT :...............................................................................................................

April - 2022
INDEX
Problem solving Using Python

S. No. Date Program Name Page. No Signature

1. Factorial of a number

2. Sum of first n given prime numbers

3. Multiplication table of a number

4. Add up columns and rows of given table

5. Validate an email address

Convert a number written in words to


6.
digit

Delay the program execution for the given


7.
number of seconds

Changes the colour of the first character


8.
of a word

Read a file, reverse its contents, and write


9.
the result back to a new file
Rename all the files with one extension to
10. another extension.

To read the current directory and return a


11.
file list sorted by last modification time

Create a student mark sheet table. Insert,


12.
delete and modify records
<?php
$servername = "localhost";
$username = "root";
$password = "myroot";
$dbname = "myDB";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
?>

<?php
require 'connect.php';
$sql = "CREATE DATABASE myDB";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
$conn->close();
?>

<?php
require 'connect.php';

$sql = "CREATE TABLE SMark (


sid INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
sname VARCHAR(30) NOT NULL,
sub1 INT(3),
sub2 INT(3),
sub3 INT(3)
)";

if ($conn->query($sql) === TRUE) {


echo "Table SMark created successfully";
} else {
echo "Error creating table: " . $conn->error;
}

$conn->close();
?>
selectTB.php

<?php
require 'connect.php';
$sql = "SELECT sid, sname, sub1, sub2, sub3 FROM SMark";
$result = mysqli_query($conn, $sql);
echo "<table border = \"1\">
<tr><th>sid</th><th>sname</th><th>sub1</th><th>sub2</th><th>sub3</th></tr>";
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo
"<tr><th>$row[sid]</th><th>$row[sname]</th><th>$row[sub1]</th><th>$row[sub2]</th><th>$
row[sub3]</th></tr>";
}
echo "</table>";
} else {
echo "</table><br>";
echo "0 results<br>";
}
echo "<form action=\"manip.php\"method=\"POST\">";
echo "<table border = \"1\">
<tr><th>sname</th><th>sub1</th><th>sub2</th><th>sub3</th></tr>";
echo "<tr><td><input type=\"text\" id=\"sname\" name=\"sname\" size=\"25\"></td>";
echo "<td><input type=\"text\" id=\"sub1\" name=\"sub1\" size=\"3\"></td>";
echo "<td><input type=\"text\" id=\"sub2\" name=\"sub2\" size=\"3\"></td>";
echo "<td><input type=\"text\" id=\"sub3\" name=\"sub3\" size=\"3\"></td></tr></table><br>";
echo "<input type=\"radio\" name=\"option\" value=\"1\"> Insert";
echo "<input type=\"radio\" name=\"option\" value=\"2\"> Delete";
echo "<input type=\"radio\" name=\"option\" value=\"3\"> Update";
echo "<input type=\"submit\"/>";
echo "</form>";
mysqli_close($conn);
?>

manip.php

<?php
$ch = isset($_POST['option']) ? $_POST['option'] : "";
if ($ch == "")
{
echo "No Operation specified";
}
else
{
require 'connect.php';
switch ($ch)
{
case 1:

$v1=$_POST['sname'];$v2=(int)$_POST['sub1'];$v3=(int)$_POST['sub2'];$v4=(int)$_POST['sub
3'];
$sql = "INSERT INTO SMark (sname, sub1, sub2, sub3)VALUES ('$v1',$v2,$v3,$v4)";

if ($conn->query($sql) === true)


{
echo "New record created successfully";
}
$conn->close();
break;
case 2:
$v1=$_POST['sname'];
$sql = "DELETE FROM SMark WHERE sname='$v1'";
if ($conn->query($sql) === true)
{
echo "Record deleted successfully";
}
$conn->close();
break;
case 3:

$v1=$_POST['sname'];$v2=(int)$_POST['sub1'];$v3=(int)$_POST['sub2'];$v4=(int)$_POST['sub
3'];
$sql = "UPDATE SMark SET sub1=$v2,sub2=$v3,sub3=$v4 WHERE sname='$v1'";
if ($conn->query($sql) === true)
{
echo "Record updated successfully";
}
$conn->close();
break;
}
}
include 'selectTB.php';
?>

Output:

You might also like