Professional Documents
Culture Documents
Practical Record: Jaya College of Arts &science THIRUNINRAVUR - 602 024
Practical Record: Jaya College of Arts &science THIRUNINRAVUR - 602 024
PRACTICAL RECORD
Register No.
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.
PRACTICAL RECORD
COURSE:................................. SEMESTER:..............................
SUBJECT :...............................................................................................................
April - 2022
INDEX
Problem solving Using Python
1. Factorial of a number
<?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';
$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)";
$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: