EX.
NO:1 ARITHMATIC OPERATION
DATE:26/12/17
**************************
AIM:
To write a php program to perform with “Arithmetic operation”
HTML coding:
<html>
<head>
<title>ARITHMATIC CALCULATION</title>
</head>
<body bgcolor="pink">
<form action="ari.php" method="get">
<font color="blue" size="5" face="monotypecorsiva">
<center>
1.Addtion<br>
2.Subraction<br>
3.Multipication<br>
4.Division<br>
first number:<input type="text" name="t1"><br><br>
second number:<input type="text" name="t2"><br><br>
choice :<input type="text" name="ch"><br><br>
<input type="submit" name="submit" value="SUBMIT">
<br></center>
</form>
</font>
</html>
PHP coding:
<?php
echo "<font color=Darkgreen size=5 face=monotype corsiva>";
$c=$_GET['ch'];
$a=$_GET['t1'];
$b=$_GET['t2'];
echo "<br>The first value is:$a";
echo "<br>The second value is:$b";
switch($c)
case 1:
$res=$a+$b;
echo "<br>Addition value is:$res";
break;
case 2:
$res=$a-$b;
echo "<br> Subraction value is:$res";
break;
case 3:
$res=$a*$b;
echo "<br>Multipication value is:$res";
break;
case 4:
$res=$a/$b;
echo "<br>Division value is:$res";
break;
echo"</font>";
?>
OUTPUT:
1.Addtion
2.Subraction
3.Multipication
4.Division
first number: 6
second number: 6
choice : 3
SUBMIT
The first value is:6
The second value is:6
Multipication value is:36
RESULT:
Thus the php program was successfully executed.
EX.NO:2 ELIGIBLE FOR VOTE DATE:06/01/18
*********************
AIM:
To write a program to perform the “Eligible for vote”
HTML coding:
<html>
<head>
<title>ALIGIBLE FOR VOTE</title>
</head>
<body bgcolor="red">
<form action="eli.php" method="get">
<font color="blue" size="5" face="monotype corsiva">
<center>
enter your age:<input type="text" name="t1"><br>
<input type="submit" name="submit" value="SUBMIT">
<br></center>
</form>
</font>
</html>
PHP coding:
<?php
echo "<font color=Darkgreen size=5 face=monotype corsiva>";
$a=$_GET[ 't1' ];
echo "<br>The age is:$a";
if(a<=18)
echo "<br> you are eligible for vote";
else
echo "<br>you are not eligible for vote";
echo "</font>"
?>
OUTPUT:
enter your age: 19
SUBMIT
The age is:19
you are eligible for vote
RESULT:
Thus the php program was succefully executed.
EX.NO:3 STUDENT MARK SHEET DATE:01/02/18
************************
AIM:
To write a php program to perform with “Student mark sheet”.
Coding:
<html>
<head>
<style>
table
border style:solid;
border width:2px;
border color:pink;
</style>
</head>
<body bgcolor="#ABCD">
<?php
$con=mysql_connect("localhost" ,"root", "");
if(!$con)
die('could not connect:'. mysql_error());
mysql_select_db("smart",$con);
$result=mysql_query("SELECT * FROM stu");
echo "<table border='1'>
<tr>
<th> Id</th>
<th> Name</th>
<th> Mobile</th>
<th> E_mail</th>
</tr>";
while($row=Mysql_fetch_array ($result))
echo "<tr>";
echo "<td>".$row['Id']."</td>";
echo "<td>".$row['Name']."</td>";
echo "<td>".$row['Mobile']."</td>";
echo "<td>".$row['E_mail']."</td>";
echo "</tr>";
echo "</table>";
mysql_close($con);
?>
</body>
</html>
OUTPUT:
RESULT:
Thus the php program was successfully executed.
Ex.no:4 STUDENT MARK DETAILS DATE:04/01/18
AIM:
To write a php coding to use display the “Student mark details”
HTML coding:
<html>
<head>
<title>STUDENT MARK DETAILS</title>
</head>
<body bgcolor="orange">
<form action="mark.php" method="GET">
<font color="pink" size="6" face="Times New Roman">
enter your name:<input type="text" name="t1"><br>
<input type="submit" name="submit" value="SUBMIT">
mark1:<input type="text" name="m1"><br>
mark2:<input type="text" name="m2"><br>
mark3:<input type="text" name="m3"><br>
mark4:<input type="text" name="m4"><br>
mark5:<input type="text" name="m5"><br>
</font>
</html>
PHP coding:
<?php
echo "<font color=Darkgreen size=5 face=times new roman>";
$a=$_GET['t1'];
$m1=$_GET['m1'];
$m2=$_GET['m2'];
$m3=$_GET['m3'];
$m4=$_GET['m4'];
$m5=$_GET['m5'];
echo "<br>The name is:$a";
echo "<br>mark1:$m1";
echo "<br>mark2:$m2";
echo "<br>mark3:$m3";
echo "<br>mark4:$m4";
echo "<br>mark5:$m5";
echo "<br>";
$total=$m1+$m2+$m3+$m4+$m5;
$avg=$total/5;
echo "the total is =$total";
echo "<br>";
echo "the avg is=$avg";
echo "<br>";
if($m1>=35&&$m2>=35&&$m3>=35&&$m4>=35&&$m5>=35)
{
echo "the result is pass";
else
echo "the result is fail";
?>
OUTPUT:
enter your name: p.poorn
mark1:
SUBMIT 80
mark2: 80
mark3: 60
mark4: 50
mark5: 45
The name is:p.poorni
mark1:80
mark2:80
mark3:60
mark4:50
mark5:45
the total is =315
the avg is=63
the result is pass
RESULT:
Thus the php program was successfully executed.
EX.NO:5 MULTPICATION TABLE DATE:02/02/18
AIM:
To write php coding to use display the “Multipication table”.
HTML coding:
<html>
<head>
<title>MULTIPICATION TABLE</title>
</head>
<body bgcolor="red">
<form action="multi.php" method="get">
<font color="blue" size="5" face="monotype corsiva">
<center>
enter your table name:<input type="text" name="t1"><br>
<input type="submit" name="submit" value="SUBMIT">
<br></center>
</form>
</font>
</html>
PHP coding:
<?php
echo "<font color=orange size=5 face=Times New Roman>";
$n=$_GET['t1'];
$i=1;
do
{
$r=$n*$i;
echo "$i*$n=$r<br>";
$i++;
}
while($i<=10);
echo "</font>";
?>
OUTPUT:
Enter your table name: 4
SUBMIT
1*4=4
2*4=8
3*4=12
4*4=16
5*4=20
6*4=24
7*4=28
8*4=32
9*4=36
10*4=40
RESULT:
Thus the php program was successfully executed.
EX.NO:6 SUM OF DIGIT DATE:16/02/18
AIM:
To write a php coding to use display with “Sum of digit”.
HTML coding:
<?php
echo "<font color=red size=5 face=times new roman>";
$a=$_GET['t1'];
echo "The value is:$a";
echo "<br>";
while($a>0)
$r=$a%10;
$s=$s+$r;
$a=$a/10;
echo "the result is:$s";
echo "</font>";
?>
OUTPUT:
Enter the value : 1234
The value is:1234
The result is:10
Result:
Thus the php program was successfully executed.
EX.NO:7 BIGGEST NUMBER DATE: 16/02/18
AIM:
To write a php coding to use display with “Biggest number”.
HTML coding.
<html>
<head>
<title>BIGGEST NUMBER</title>
</head>
<body bgcolor="red">
<form action="big.php" method="get">
<font color="blue" size="5" face="monotype corsiva">
<center>
first number:<input type="text" name="t1"><br>
second number:<input type="text" name="t2"><br>
<input type="submit" name="submit" value="SUBMIT">
<br></center>
</form>
</font>
</html>
PHP coding:
<?php
echo "<font color=green size=5 face=times new roman>";
$a=$_GET['t1'];
$b=$_GET['t2'];
function biggest($a,$b)
{
if($a>$b)
echo "<br>$a";
else
echo "<br>$b";
echo "<br>The first value is:$a";
echo "<br>The second value is:$b";
echo "<br>The biggest number is";
biggest($a,$b);
echo "</font>";
?>
OUTPUT:
First number: 80
Second number:90
SUBMIT
The first value is : 80
The second value is : 90
The biggest value is :90.
Result:
Thus the PHP program was successfully executed.
EX.NO:8 STRING MANIPULATION DATE: 21/02/2018
AIM:
To write a php coding to use with display the “String manipulation”.
HTML coding:
<html>
<head>
<title>STRING MANIPULATION</title>
</head>
<body bgcolor="blue">
<form action="string.php" method="get">
<font color="red" size="5" face="monotype corsiva">
<center>
string1:<input type="text" name="t1"><br>
<input type="submit" name="submit" value="SUBMIT">
<br></center>
</form>
</font>
</html>
PHP coding:
<?php
echo "<font color=red size=6 face=times new roman>";
$a=$_GET['t1'];
echo "The string1 is: $a<br>";
echo "The length is: ".strlen($a);
echo "<br>The upper case is:".strtoupper($a);
echo "<br>The lower case is:".strtolower($a);
echo "<br>The reverse is:".strrev($a);
?>
OUTPUT:
String 1: p.poornammal
The string 1 is: p.poornammal
The length is:12
The upper case is:P.POORNAMMAL
The lower case is: p.poornammal
The reverse is: lammanroop.p
RESULT:
Thus the php program was successfully executed.
Ex.no:9 MULTIPLE OF 7 USING REQUIRE DATE:23/02/18
AIM:
To write a php code to display with “
<?php
$a=0;
while($a<=100)
echo "<br>$a";
$a=$a+7;
?> <?php
echo "<font color=blue size=5 face=Times new roman>";
require 'mu.php';
echo "</font>";
?>
OUTPUT
7
CREATE DATABASE:
mysql> create database salesdept;
Query OK, 1 row affected (0.00 sec)
mysql> use salesdept;
Database changed
CREATE TABLE:
mysql> create table product(sno int(3),proid int(3),proname text(15),prize int(3));
Query OK, 0 rows affected (0.06 sec)
INSERT INTO THE TABLE:
mysql> insert into product values(1,101,'Hamam',30),(2,102,'Skil',200),(3,103,'milk',20);
Query OK, 3 rows affected (0.03 sec)
Records: 3 Duplicates: 0 Warnings: 0
DISPLAY THE TABLE:
mysql> select * from product;
__________________________
sno proid proname prize
__________________________
1 101 Hamam 30
2 102 Skil 200
3 103 milk 20
___________________________
3 rows in set (0.02 sec)
UPDATE OUERY:
mysql> update product set prize=30 where proid=101;
Query OK, 0 rows affected (0.02 sec)
Rows matched: 1 Changed: 0 Warnings: 0
DELETE THE ONE COLUMN:
mysql> delete from product where proid=101;
Query OK, 1 row affected (0.05 sec)
_________________________________
sno proid proname prize quantity
__________________________________
2 102 Skil 200 NULL
3 103 milk 20 NULL
___________________________________
ALTER TABLE:
mysql> alter table product add(quantity int(10));
Query OK, 2 rows affected (0.19 sec)
Records: 2 Duplicates: 0 Warnings: 0
DISPLAY THE TABLE:
mysql> select * from product;
___________________________________
sno proid proname prize quantity
__________________________________
2 102 Skil 200 NULL
3 103 milk 20 NULL
____________________________________
2 rows in set (0.00 sec)
mysql> alter table product motify quantity int(10);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'motif
y quantity int(10)' at line 1
mysql> alter table product modify quantity int(10);
Query OK, 2 rows affected (0.14 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select * from product;
+------+-------+---------+-------+----------+
| sno | proid | proname | prize | quantity |
+------+-------+---------+-------+----------+
| 2 | 102 | Skil | 200 | NULL |
| 3 | 103 | milk | 20 | NULL |
+------+-------+---------+-------+----------+
2 rows in set (0.00 sec)
mysql> rename table product to sales product;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'produ
ct' at line 1
mysql> rename table product to purchase;
Query OK, 0 rows affected (0.03 sec)
mysql> select * from purchase;
+------+-------+---------+-------+----------+
| sno | proid | proname | prize | quantity |
+------+-------+---------+-------+----------+
| 2 | 102 | Skil | 200 | NULL |
| 3 | 103 | milk | 20 | NULL |
+------+-------+---------+-------+----------+
2 rows in set (0.00 sec)
mysql> desc purchase;
+----------+----------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+----------+------+-----+---------+-------+
| sno | int(3) | YES | | NULL | |
| proid | int(3) | YES | | NULL | |
| proname | tinytext | YES | | NULL | |
| prize | int(3) | YES | | NULL | |
| quantity | int(10) | YES | | NULL | |
+----------+----------+------+-----+---------+-------+
5 rows in set (0.02 sec)
mysql>
mysql> create table bill(cusno int(3),couname text(15),place text(10),preamt int
(3),correntamt int(3));
Query OK, 0 rows affected (0.05 sec)
mysql> insert into bill values(101,'poorni','house',2,4);
Query OK, 1 row affected (0.02 sec)
mysql> insert into bill values(102,'jaya','school',1.50,2.50);
Query OK, 1 row affected (0.03 sec)
mysql> insert into bill values(103,'buvana','busniess',3,2.50);
Query OK, 1 row affected (0.03 sec)
mysql> select * from bill;
+-------+---------+----------+--------+------------+
| cusno | couname | place | preamt | correntamt |
+-------+---------+----------+--------+------------+
| 101 | poorni | house | 2| 4|
| 102 | jaya | school | 2| 3|
| 103 | buvana | busniess | 3| 3|
+-------+---------+----------+--------+------------+
3 rows in set (0.00 sec)
<html>
<head>
<style>
table
border style:solid;
border width:2px;
border color:pink;
</style>
</head>
<body bgcolor="#ABCD">
<?php
$con=mysql_connect("localhost" ,"root", "");
if(!$con)
die('could not connect:'. mysql_error());
mysql_select_db("eb",$con);
$result=mysql_query("SELECT * FROM bill");
echo "<table border='1'>
<tr>
<th> Customer No</th>
<th> Customer Name</th>
<th> Customer Type</th>
<th>consumption</th>
<th> Bill</th>
</tr>";
while($row=Mysql_fetch_array ($result))
$unit=$row['correntamt']-$row['preamt'];
$cty=$row['place'];
if ($cty=='house')
$amt=$unit*2.50;
elseif($cty=='school')
$amt=$unit*1.50;
else
$amt=$unit*3.50;
echo "<tr>";
echo "<td>".$row['cusno']."</td>";
echo "<td>".$row['couname']."</td>";
echo "<td>".$cty."</td>";
echo "<td>".$unit." unit"."</td>";
echo "<td>".$amt."</td>";
echo "</tr>";
echo "</table>";
echo "House --->2.50 per unit School-->Rs.1.50 per unit others-->3.50";
mysql_close($con);
?>
</body>
</html>
House --->2.50 per unit School-->Rs.1.50 per unit others-->3.50