Open Source Software Lab

You might also like

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

Open Source Software Lab

---------------------------------------------
1. CREATE A WEB PAGE WITH FRAMES AND TABLES

Book Store

<html>
<head>
<title>Book Store </title></head>
<body>
<frameset rows="18%,*">
<frame src="topframe.html" scrolling="no">
<frameset cols="15%,*">
<frame src="leftframe.html" noresize/>
<frame src="rightframe.html" name="rframe"/>
</frameset>
</frameset>
</body>
</html>

Top frame

<html>
<head>
<title>Top Frame </title></head>
<body bgcolor=#bbffbb>
<table border=”1” width=”100%”>
<tr>
<th width="14%">
<imgsrc="shop.jpg" width=100 height=50/>
</th>
<th width="80%"><u>Online Book Shopping</U></th>
</tr></table>

<table border="1" width="100%">


<tr>
<th><a href="rightframe.html"
target="rframe">Home</a></th>
<th><a href="catalogue.html"
target="rframe">Catalogue</a></th>
</tr>
</table>
</body></html>

Left Frame

<html>
<head><title>Left frame </title></head>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
<body bgcolor=#ffffcc><center>
<h4><a href="cse.html" target="rframe">Computer
Science</a></h4>
<h4><a href="it.html" target="rframe">IT</a></h4>
</center></body>
</html>

Right Frame

<html>
<head><title>Right frame </title></head>
<body bgcolor="Silver">
<h2>Welcome To Online Book Shopping</h2>
<h1><u><center>Welcome To A AGovt Arts
College,VPM</center></u></h1>
</body>
</html>

Catalogue

<html>
<title>Catalogue </title>

<body bgcolor="pink">
<form>
<table border="1" width="100%"><tr>
<td><imgsrc="java.jpg" width=100 height=100/></td>
<td>Book:Java Programming <br>Author:C.Muthu<br> Tata
Publication, Chennai.</td>
<td>Rs.150 &nbsp; &nbsp; &nbsp; &nbsp;</td>
<td><input type="button" value="Add ToCart"/></td></tr>
<tr><td><imgsrc="internet.jpg" width=100
height=100/></td>
<td>Book:Internet and its
Application<br>Author:P.Rizwan<br> Tata Mcgrow
Publications, Chennai.</td>
<td>Rs.150 &nbsp; &nbsp; &nbsp; &nbsp;</td><td>
<input type="button" value="Add To Cart"/></td></tr>
</table></from>
</body></html>

Computer Science

<html>
<body bgcolor="scanda" text="black">
<h2><b><u><i>Book List<br></b></u></i></h2>
<h3>Internet and its Application<br>
<ol>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
<li>Data Mining<br>
<li>Cryptography<br>
<li>Microprocessor and its Application<br>
<li>Programming in C++ and Data Structure<br>
<li>Digital Logic And Microprocessor<br>
</ol>
</h3>
</body>
</html>
IT

<html>
<body bgcolor="skyblue" text=black>
<h2><b><u><i>Book List<br></b></u></i></h2>
<h3>Data Mining<br>
<ol>
<li>Network Security and Cryptography<br>
<li>Mobile Computing<br>
<li>Open Source Software<br></h3>
</ol>
</body>
</html>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

output

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
2. CREATE A WEB PAGE INCORPORATING CSS

XYZ.CSS

h3{font-family:arial;font-size:20;color:cyan}
table{border-color:green} td{font-
size:20pt;color:magenta}
Main

<html>
<head><h1><center>ALL STYLE SHEETS</CENTER></H1>
<title>Use of INTERNAL and EXTERNAL STYLE SHEETS</title>
<link rel="stylesheet" href="xyz.css" type="text/css">
<style type="text/css">
.vid{font-family:verdana;font-
style:italic;color:red;text-align:center}
.ani{font-family:tahoma;font-style:italic;font-
size:20;text-align:center}
font{font-family:georgia;font-
size:20;color:blue;}ul{list-style-type:circle}</style>
</head>
<body>
<ol style="list-style-type:lower-alpha">
<b><center>A AGovt Arts COLLEGE,
Villupuram.</center><b><br><br>
<li>Department of Computer Science
<li>PG Department of Information Technology
<li>PG & Research Department of Computer Science
</ol>

<center><p style="font-size:20pt;color:purple">Mrs
BHARATHI, HOD</p></center>
<p class="ani">A A Govt Arts College, Villupuram-
605602<br>Afflicated to Thiruvalluvar
University,Vellore-623 115<br></p>
<h2 class="vid">GovermentAidedCollege</h2>
<font><hr><h2>List of Courses offered</h2></hr>
<ul><li>B.Com Genaral</li>
<li>B.Sc Mathematics</li>
<li>B.Sc Computer Science</li>
<li>B.A English</li>
<li>BBA</li>
<li>BCA</li>
<li>B.Com Computer Application</li>
<li>M.Sc IT</li>
<li>M.Sc Mathematics</li>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
</ul>
</font>
<h3>Result of BCA Student </h3>
<table width="100%" cellpadding="2" border="5">
<tr><th>S.NAME</TH>
<th>MARKS</th>
<th>Result</th>
</tr>
<tr><td align="center"> Xavier</td>
<td align="center"> 100</td>
<td align="center"> Pass</td></tr>
<tr><td align="center">Devishree</td>
<td align="center"> 99</td>
<td align="center"> Pass</td></tr>
<tr><td align="center">Arun</td>
<td align="center"> 98</td>
<td align="center"> Pass</td></tr>
</table></body></html>

OUTPUT

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

3. WRITE A SHELL PROGRAM TO FIND THE FACTORIAL OF


ANINTEGER POSITIVE NUMBER.

echo "ENTET A POSITIVE NUMBER"


read n
f=1
until test $n -lt 1;
do
f=`expr $f \* $n`
n=`expr $n - 1`
done
echo "FACTIORIAL IS $f"

OUTPUT

admin@linux-rei3:~>sh fac.sh
ENTET A POSITIVE NUMBER
5
FACTIORIAL IS 120

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

4. WRITE A SHELL PROGRAM FOR CHECKING WHETHER A


GIVEN STRING IS A PALINDROME OR NOT.
admin@linux-rei3:~> vi p.sh
clear
echo "Enter a string"
read str
echo
len=`echo $str | wc -c`
len=`expr $len - 1`
i=1
j=`expr $len / 2`
echo "j= $j ; len=$len;;"
while test $i -le $j;
do
k=`echo $str | cut -c $i`
l=`echo $str | cut -c $len`
if test $k != $l;
then
echo "Not Palindrome"
exit
fi
i=`expr $i + 1`
len=`expr $len - 1`
echo " i = $i len = $len; k = $k; l=$l"
done
echo "Palindrome"

OUTPUT

Enter a string
madam

j= 2 ; len=5;;
i = 2 len = 4; k = m; l=m
i = 3 len = 3; k = a; l=a
Palindrome

Enter a string
abcdefg

j= 3 ; len=7;;
Not Palindrome

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
5. CREATE SIMPLE CALCULATOR IN JAVA SCRIPT
<html>
<head>
<title>Calculator</title>
<script type="text/javascript">
varres,t,m,p,q;
function prs(a,c)
{
res=a + c;
return res;
}
function prs1(a,c)
{
p=a
t=c;
document.f1.t1.value="";
}
function eq(c)
{
if(t=="+")
{
q=eval(p)+eval(c);
}
if(t=="-")
{
q=eval(p)-eval(c);
}
if(t=="*")
{
q=eval(p)*eval(c);
}

if(t=="/")
{
q=eval(p)/eval(c);
}
return(q);
}

function clear_text(m,n)
{
document.f1.t1.value="";
}
</script>
</head>
<body>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
<form name=f1>
<input type="textbox" name="t1" size="30"><br><br><br>
<input type="button" name="c" value ="1"
onclick="t1.value=prs(t1.value,c.value);"
>&nbsp;&nbsp;&nbsp
<input type="button" name="c1" value ="2"
onclick="t1.value=prs(t1.value,c1.value);"
>&nbsp;&nbsp;&nbsp
<input type="button" name="c2" value ="3"
onclick="t1.value=prs(t1.value,c2.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name="c12" value ="+"
onclick="prs1(t1.value,c12.value);"><br><br><br>
<input type="button" name="c3" value= "4"
onclick="t1.value=prs(t1.value,c3.value);">&nbsp;&nbsp;
&nbsp

<input type="button" name="c4" value ="5"


onclick="t1.value=prs(t1.value,c4.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name="c5" value ="6"
onclick="t1.value=prs(t1.value,c5value);">&nbsp;&nbsp;&
nbsp
<input type="button" name="c13" value ="-"
onclick="prs1(t1.value,c13.value);"><br><br><br>
<input type="button" name="c6" value ="7"
onclick="t1.value=prs(t1.value,c6.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name ="c7" value ="8"
onclick="t1.value=prs(t1.value,c7.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name="c8" value= "9"
onclick="t1.value=prs(t1.value,c8.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name="c14" value ="*"
onclick="prs1(t1.value,c14.value);"><br><br><br>
<input type="button" name ="c9" value ="."
onclick="t1.value=prs(t1.value,c9.value);">&nbsp;&nbsp;
&nbsp
<input type="button" name ="c10" value ="0"
onclick="t1.value=prs(t1.value,c10.value);">&nbsp;&nbsp
;&nbsp
<input type="button" name ="c11" value ="="
onclick="t1.value=eq(t1.value);">&nbsp;&nbsp;&nbsp
<input type="button" name="c15" value ="/"
onclick="prs1(t1.value,c15.value);"><br><br><br>
<input type="button" name="c16" value ="cls"
onclick="clear_text();"><br><br><br>
</form>
---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
OUTPUT

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
6. Write a JavaScript program to scroll your name
in the scroll bar.
<html>
<head>
<script lang="javascript">
document.write('<style type="text/css">');
document.write("#textarea {");
document.write("background-color:#009999;");
document.write("SCROLLBAR-HIGHLIGHT-COLOR:#3366cc; ");
document.write("SCROLLBAR-SHADOW-COLOR:#000099; ");
document.write("SCROLLBAR-ARROW-COLOR:#000099; ");
document.write("SCROLLBAR-TRACK-COLOR:#000099; ");
document.write("SCROLLBAR-DRAKSHADOW-COLOR:#000099; ");
document.write("SCROLLBAR-BASE-COLOR:#6699ff; ");
document.write(" }");
document.write("</style>");
</script></head>
<body>
<textarea id="textarea" rows="10" cols="38">
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.

A AGovt Arts COLLEGE, Villupuram.


A AGovt Arts COLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
A AGovtArtsCOLLEGE, Villupuram.
</textarea></body></html>
<html>
<head>
<STYLE TYPE="text/css">

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
BODY {
scrollbar-arrow-color:#F2B30d;
scrollbar-track-color:#FFFFCC;
scrollbar-shadow-color:#FFFFFF;
scrollbar-face-color:#FFFFCC;
scrollbar-drakshadow-color:#F2B30d;
scrollbar-3dlight-color:#F2B30d;
}
</STYLE>
</head>
</html>

OUTPUT

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
7. DEVELOP A PROGRAM AND CHECK MESSAGE PASSING MECHANISM
BETWEEN PAGES.

<html>
<head><title>My Form</title></head>
<?php
//Capture the values posted to the php program from the
text fields
//which were named 'your name ' and ' favorite word '
respectivily
$College=$_REQUEST['college'];
$Dept=$_REQUEST['department'];
?>
<body bgcolor="green" text="white">
<p>
<h2>Hi Your College Name is<br>
<b><?php print $College; ?></b></h2>
<p>
<br>
<h3>Your Department is <br>
<b><?php print $Dept;?>!?!</b></h3>
</body>
</html>

form.html

<html>
<head><title>My Form</title>
</head>
<body>
<form action="favorite.php" method=post>

<table cellspacing=0 cellpading=0 border=0>


<tr>
<td>College Name:
<td><input type="text" name="college" size=50>
</tr>
<tr>
<td>Department Name
<td><input type="text" name="department" size=50>
</tr>
<tr>
<td>
<input type="submit" name="submit" value="Display!">
</tr>
</form>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
</body>
</html>

OUTPUT

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
8. DEVELOP A PROGRAM AND CHECK FILE SYSTEM FUNCTIONS,
DATE & TIME FUNCTIONS.

<html>
<head>
<title>Welcome To MazharulUloom College</title>
</head>
<body>
UG Courses Offered:<BR>
B.A Corporate Economics<BR>
B.ScMethematics<BR>
B.Sc Computer Science<BR>
B.Com<BR>
B.Com Corporate SecretaryShip<BR>
BCA<BR>
BBA<BR>
B.Sc Microbiology<BR>
B.Com Computer Application<BR>
B.A Functional English
B.ScInformaton System Management<BR><BR><BR>
PG Courses Offered:<BR>
M.ScInfomation Technology<BR>
M.Com<BR>
M.ScMethematics<BR>
M.A English<BR><BR><BR>
Research Courses Offered:<BR>
M.Phil Computer Science - FT/PT<BR>
M.Phil Commerce - FT/PT<BR>
Ph.D Computer Science - FT/PT<BR>
Ph.D Commerce - FT/PT<BR>
Ph.D English - FT/PT<BR>
</body>
</html>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
P.php

<?php
echo("<h3>Result With Date():</h3><br/>");
echo("<br><b>".date("1")."</b><br/>");
echo("<br><b>".date("1 dS \of F Y h:i:s
A")."</b><br/>");
echo("<br><b>".date("1 dS F Y ")."</b><br/>");
echo("<h3>Oct 3,1975 was on a
".date("1",mktime(0,0,0,10,3,1975))."</h3><br />");
echo("<h3>Result With GMDate():</h3><br/>");
echo("<br><b>".gmdate("1")."</b><br/>");
echo("<br><b>".gmdate("1 dS \of F Y h:i:s
A")."</b><br/>");
echo("<br><b>".gmdate("1 dS F Y ")."</b><br/>");
echo("<h3>Oct 3,1975 was on a
".gmdate("1",mktime(0,0,0,10,3,1975))."</h3><br />");
echo("<br><b>TIME".time()."</b><br />");
?>

Filesysfun.php

<<html>
<head>
<title>Welcome To AAGAC</title>
</head>
<body bgcolor="#999999"
<pre>
<?php
$filename="getmethod.html";
$fh=fopen("$filename","r");
while(!feof($fh)){
$content=fgets($fh);
echo $content."<BR>";
}
fclose($fh);
?>
</pre>
</body>
</html>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
Output

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
9.Create a student database table in MYSQL and manipulate records (insert,
delete, update) records in a web browser.

Add.php
<html>
<head>
<title>Add Data</title>
</head>

<body>
<?php
//including the database connection file
include_once("config.php");

if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$age = $_POST['age'];
$email = $_POST['email'];

// checking empty fields


if(empty($name) || empty($age) || empty($email)) {
if(empty($name)) {
echo "<font color='red'>Name field is
empty.</font><br/>";
}

if(empty($age)) {
echo "<font color='red'>Age field is
empty.</font><br/>";
}

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
if(empty($email)) {
echo "<font color='red'>Email field is
empty.</font><br/>";
}
//link to the previous page
echo "<br/><a
href='javascript:self.history.back();'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
$result = mysqli_query($mysqli, "INSERT INTO
users(name,age,email) VALUES('$name','$age','$email')");

//display success message


echo "<font color='green'>Data added
successfully.";
echo "<br/><a href='index.php'>View Result</a>";
}
}
?>
</body>
</html>

Config.php
<html>
<head>
<title>Add Data</title>
</head>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

<body>
<?php
//including the database connection file
include_once("config.php");

if(isset($_POST['Submit'])) {
$name = $_POST['name'];
$age = $_POST['age'];
$email = $_POST['email'];

// checking empty fields


if(empty($name) || empty($age) || empty($email)) {
if(empty($name)) {
echo "<font color='red'>Name field is
empty.</font><br/>";
}

if(empty($age)) {
echo "<font color='red'>Age field is
empty.</font><br/>";
}

if(empty($email)) {
echo "<font color='red'>Email field is
empty.</font><br/>";
}

//link to the previous page

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
echo "<br/><a
href='javascript:self.history.back();'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
$result = mysqli_query($mysqli, "INSERT INTO
users(name,age,email) VALUES('$name','$age','$email')");

//display success message


echo "<font color='green'>Data added
successfully.";
echo "<br/><a href='index.php'>View Result</a>";
}
}
?>
</body>
</html>

delete.php
//including the database connection file
include("config.php");
//getting id of the data from url
$id = $_GET['id'];
//deleting the row from table
$result = mysqli_query($mysqli, "DELETE FROM users WHERE
id=$id");
//redirecting to the display page (index.php in our
case)
header("Location:index.php");

edit.php
<?php
// including the database connection file

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
include_once("config.php");

if(isset($_POST['update']))
{
$id = $_POST['id'];

$name=$_POST['name'];
$age=$_POST['age'];
$email=$_POST['email'];

// checking empty fields


if(empty($name) || empty($age) || empty($email)) {
if(empty($name)) {
echo "<font color='red'>Name field is
empty.</font><br/>";
}

if(empty($age)) {
echo "<font color='red'>Age field is
empty.</font><br/>";
}

if(empty($email)) {
echo "<font color='red'>Email field is
empty.</font><br/>";
}
} else {
//updating the table
$result = mysqli_query($mysqli, "UPDATE users SET
name='$name',age='$age',email='$email' WHERE id=$id");

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

//redirectig to the display page. In our case, it


is index.php
header("Location: index.php");
}
}
?>
<?php
//getting id from url
$id = $_GET['id'];

//selecting data associated with this particular id


$result = mysqli_query($mysqli, "SELECT * FROM users
WHERE id=$id");

while($res = mysqli_fetch_array($result))
{
$name = $res['name'];
$age = $res['age'];
$email = $res['email'];
}
?>

<html>
<head>
<title>Edit Data</title>
</head>

<body>
<a href="index.php">Home</a>
---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
<br/><br/>

<form name="form1" method="post" action="edit.php">


<table border="0">
<tr>
<td>Name</td>
<td><input type="text" name="name"
value="<?php echo $name;?>"></td>
</tr>
<tr>
<td>Age</td>
<td><input type="text" name="age"
value="<?php echo $age;?>"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email"
value="<?php echo $email;?>"></td>
</tr>
<tr>
<td><input type="hidden" name="id"
value=<?php echo $_GET['id'];?>></td>
<td><input type="submit" name="update"
value="Update"></td>
</tr>
</table>
</form>
</body>
</html>

index.php
<?php

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
//including the database connection file
include_once("config.php");

//fetching data in descending order (lastest entry first)


//$result = mysql_query("SELECT * FROM users ORDER BY id
DESC"); // mysql_query is deprecated
$result = mysqli_query($mysqli, "SELECT * FROM users
ORDER BY id DESC"); // using mysqli_query instead
?>

<html>
<head>
<title>Homepage</title>
</head>

<body>
<a href="add.html">Add New Data</a><br/><br/>

<table width='80%' border=0>


<tr bgcolor='#CCCCCC'>
<td>Name</td>
<td>Age</td>
<td>Email</td>
<td>Update</td>
</tr>
<?php
//while($res = mysql_fetch_array($result)) { //
mysql_fetch_array is deprecated, we need to use
mysqli_fetch_array
while($res = mysqli_fetch_array($result)) {

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
echo "<tr>";
echo "<td>".$res['name']."</td>";
echo "<td>".$res['age']."</td>";
echo "<td>".$res['email']."</td>";
echo "<td><a
href=\"edit.php?id=$res[id]\">Edit</a> | <a
href=\"delete.php?id=$res[id]\" onClick=\"return
confirm('Are you sure you want to
delete?')\">Delete</a></td>";
}
?>
</table>
</body>
</html>

View.php
<?php
//including the database connection file
include_once("config.php");

//fetching data in descending order (lastest entry first)


//$result = mysql_query("SELECT * FROM users ORDER BY id
DESC"); // mysql_query is deprecated
$result = mysqli_query($mysqli, "SELECT * FROM users
ORDER BY id DESC"); // using mysqli_query instead
?>

<html>
<head>
<title>Homepage</title>
</head>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
<body>
<a href="add.html">Add New Data</a><br/><br/>

<table width='80%' border=0>


<tr bgcolor='#CCCCCC'>
<td>Name</td>
<td>Age</td>
<td>Email</td>
<td>Update</td>
</tr>
<?php
//while($res = mysql_fetch_array($result)) { //
mysql_fetch_array is deprecated, we need to use
mysqli_fetch_array
while($res = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>".$res['name']."</td>";
echo "<td>".$res['age']."</td>";
echo "<td>".$res['email']."</td>";
echo "<td><a
href=\"edit.php?id=$res[id]\">Edit</a> | <a
href=\"delete.php?id=$res[id]\" onClick=\"return
confirm('Are you sure you want to
delete?')\">Delete</a></td>";
}
?>
</table>
</body>
</html>

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
OUTPUT:

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------
10. Develop a program using Cookies and session

<!DOCTYPE html>
<?php
$cookie_name="college";
$cookie_value=" ARIGNAR ANNA ARTS AND SCIENCE GOVERNMENT
COLLEGE VILLUPURAM ";
setcookie($cookie_name, $cookie_value,
time()+(86400*30),"/"); // 56400=1 day
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$cookie_name])){
echo"Cookie named'".$cookie_name."' is not set!";
}
else
{
echo"Cookie'".$cookie_name."' is set!<br>";
echo"Value is :" .$_COOKIE[$cookie_name];
}
?>
<p><strong>Note:</strong> you might have to relaod the
page to see the value of the cookie.</p>
</body>
</html>

<!DOCTYPE html>
<?php
session_start();
if (isset($_SESSION['count']))
{
echo "You Have Vistited the Page in &nbsp<b>" .
$_SESSION['count'] . "</b>&nbsp times<br>";
$_SESSION['count']++;
}
else
{
$_SESSION['count']=1;
echo " This is the First Time You visit this page";
}
?>
---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram
Open Source Software Lab
---------------------------------------------

OUTPUT

---------------------------------------------
Aringar Anna Govt. Arts College, Villupuram

You might also like