PHP Lab Final1
PHP Lab Final1
5 MATH FUNCTION
6 COOKIES
7 DISPLAY STUDENT INFORMATION USING
MYSQL TABLE
8 GENBAK USING BIOPERL
9 COMPARE SEQUENCES AND FIND MUTATION
USING BIOPERL
10 SIMULATE DNA MUTATION
11 PROTEIN SEQUENCE GENERATION
12 DNA FRAGMENTS TRANSCRIPTION : DNA TO
RNA
ALGORITHM :
STEP 2: Go to the editor for coding the controls and functions programs in PHP
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 5: using control statements find the biggest among two variables
STEP 6: create another block of statements for favourite site using switch
statement
STEP 7: print values and run the local host using browser
$first_number=7;
$second_number=21;
if($first_number>$second_number){
else
$favorite_site='code';
switch($favorite_site){
case'business':
break;
case'code':
break;
case'web design':
break;
case'music':
break;
case'photography':
break;
default:
$max=0;
echo $i=0;
echo",";
echo $j=1;
echo",";
$result=0;
while($max<10)
$result=$i+$j;
$i=$j;
$j=$result;
$max=$max+1;
echo $result;
echo",";
?>
AIM: To Develop a PHP program to implement the concept of String and arrays
ALGORITHM:
STEP 2: Go to the editor for creating the associative array and strings program
in PHP
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 7: Run the local host using browser and call the program
<html>
<head>
<title>associative array</title>
</head>
<body>
<?php
$marks=array(
"mohammad"=>array(
"physics"=>35,
"maths"=>30,
"chemistry"=>39
),
"qadir"=>array(
"physics"=>30,
"maths"=>32,
"chemistry"=>29
),
"zara"=>array(
"physics"=>31,
"maths"=>22,
"chemistry"=>39
);
echo $marks['mohammad']['maths']."<br/>";
echo $marks['mohammad']['chemistry']."<br/>";
echo $marks['mohammad']['physics']+$marks['mohammad']['maths']+
$marks['mohammad']
['chemistry']."<br/>";
echo"<br/>";
echo $marks['qadir']['physics']."<br/>";
echo $marks['qadir']['maths']."<br/>";
echo $marks['qadir']['chemistry']."<br/>";
echo $marks['qadir']['physics']+$marks['qadir']['maths']+$marks['qadir']
['chemistry']."<br/>";
echo"<br/>";
echo $marks['zara']['physics']."<br/>";
echo $marks['zara']['maths']."<br/>";
echo $marks['zara']['chemistry']."<br/>";
echo $marks['zara']['physics']+$marks['zara']['maths']+$marks['zara']
['chemistry']."<br/>";
echo"<br/>";
?>
</body>
</html>
ALGORITHM:
STEP 2: Go to the editor for coding the grade displaying programs in PHP
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 4: create a form using html tags and create a table with fields student
name Marks for physics, chemistry and maths
STEP 5: check the input element is set or not using set() function
STEP 6: Add necessary fields and access value from each text field
STEP 7: Find the total marks and set the appropriate grade format using if
statement
STEP 10: print values and run the local host using browser
<html>
<body>
<center>
<table border=0>
<tr>
<td>
Student Name
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
<br>
<br>
</center>
<?php
$sum=$a1+$a2+$a3;
if($avg>=0&&$avg<=50)
$grade="Fail";
if($avg>=50&&$avg<=70)
$grade="C";
if($avg>=70&&$avg<=80)
$grade="B";
if($avg>=80&&$avg<=90)
$grade="A";
if($avg>90)
$grade="E";
echo "<br>";
".$sum."</center><br>";
?>
</form>
</body>
</html>
ALGORITHM:
STEP 1: Start the process
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 7: use the input type function to submit the entered the details
STEP 9: Run the local host using the browser and calls the program
<html>
<head>
</head>
<body>
<div>
<?php
if(isset($_POST['create']))
?>
</div>
<div>
<div class="container">
<h1>Registration</h1>
<label for="addr"><b>Address</b></label>
<label for="email"><b>E-Mail</b></label>
</div>
</form>
</body>
</html>
ALGORITHM:
STEP 1: Start the process
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 9: Run the local host using the browser and calls the program
<?php
$marks1=array(360,310,310,330,313,375,456,111,256);
$marks2=array(350,340,356,330,321);
$marks3=array(630,340,570,635,434,255,298);
$max_marks = max(max($marks1),max($marks2),max($marks3));
$min_marks = min(min($marks1),min($marks2),min($marks3));
echo"Maximummarks : ",$max_marks."\n";
echo"Minimummarks : ",$min_marks."\n";
$val='4.5e3';
$ival=(int) $val;
$fval=(float) $val;
echo $ival,"\n";
echo $fval,"\n";
$odate="2012-09-12";
$newDate=date("d-m-y",strtotime($odate));
echo $newDate,"\n";
?>
Algorithm:
STEP 1: Start the process
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 5: use input type function to perform operations like read and delete
cookies
STEP 8: Run the local host using the browser and calls the program
<html>
<head>
<title>cookies</title>
<?php
?>
</head>
<body>
<h1>
seting a cookie
</h1>
<form action="phpgetcookie.php">
</form></body></html>
Phpgetcookie.php
<html>
<head><title>cookies</title>
</head>
<body>
<h1>
if(isset($_COOKIE['message']))
echo $_COOKIE['MESSAGE'];
?>
<form action="setcookie.php">
</form>
</body>
</html>
Setcookie.php
<html>
<head>
<title>cookies</title>
<?php
setcookie("message"," ",time()-3600);
?>
</head>
<body>
<form action="phpgetcookie.php">
</form>
</body></html>
ALGORITHM:
STEP 1: Start the process
STEP 2: Go to the editor for coding the student information program in PHP
STEP 3: Program code starts with opening and closing tag for PHP
programming
STEP 7: use the input type function to submit the entered the details
STEP 9: Run the local host using the browser and calls the program
Student.php
<html>
<head>
<title>database</title>
</head>
<body>
<form action="student.php"method="POST">
<input type="submit"name="insert"value="INSERT">
<input type="submit"name="update"value="UPDATE">
<input type="submit"name="delete"value="DELETE">
</form>
</body>
</html>
Student.php
<html>
<head>
<title>database</title>
</head>
<body>
<?php
$X=$_POST['c'];
$y=$_POST['a'];
$z=$_POST['b'];
$con=mysql_connect("localhost","root","");
mysql_select_db("prabu",$con);
echo"Row inserted";
if(isset($_POST['update']))
$X=$_POST['c'];
$y=$_POST['a'];
$z=$_POST['b'];
$con=mysql_connect("localhost","root","");
mysql_select_db("prabu",$con);
echo"Row updated";
if(isset($_POST['delete']))
$x=$_POST['e'];
$con=mysql_connect("localhost","root","");
mysql_select_db("prabu",$con);
?>
</body>
<html>
ALGORITHM:
STEP 3: Get the sequence of (AF303112) in seq1 and trunk it in seq2 Using trunc(1, 200)
:#!/local/bin/perl -w
use Bio::DB::GenBank;
$seq1 = $gb->get_Seq_by_acc('AF303112');
$seq2=$seq1->trunc(1, 200);
exit;
GENBANK/AF303112
GENBANK/AY050559
AIM: To write a script to use sequence feature to compare sequence and find mutation using bioperl.
ALGORITHM:
STEP 3: Declare sub mutate to get the current base and new base of DNA.
STEP 5: Print the file name to getting the sequence which is compared and mutant.
use File::Path;
$dnafilename = <STDIN>;
chomp $dnafilename;
goto h;
my $DNA = <DNAFILE>;
close DNAFILE;
my $i;
my $mutant;
$mutant = mutate($DNA);
print "$DNA\n\n";
print "$mutant\n\n";
$mutant = mutate($mutant);
print "$mutant\n";
sub mutate
my($dna) = @_;
my($position) = randomposition($dna);
my $newbase;
do
$newbase = randomnucleotide();
substr($dna,$position,1,$newbase);
return $dna;
subrandomposition
my($string) = @_;
subrandomelement
my(@array) = @_;
subrandomnucleotide
use File::Path;
$dnafilename = <STDIN>;
chomp $dnafilename;
goto h;
my $DNA = <DNAFILE>;
close DNAFILE;
ALGORITHM:
#! /usr/bin/perl -w
# Storing DNA in a variable, and printing it out
# First we store the DNA in a variable called $DNA
$DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC';
# Next, we print the DNA onto the screen
print $DNA;
# Finally, we'll specifically tell the program to exit.
Exit;
ALGORITHM:
STEP 3: Declare DNA1 and DNA2 to store DNA fragments and print.
STEP 4: Transcribe the DNA to RNA by substituting all T’s with U’s .
print"*************************\n\n";
# The DNA
$DNA = 'ACGGGAGGACGGGAAAATTACTACGGCATTAGC';
print "$DNA\n\n";
$RNA = $DNA;
$RNA =~ s/T/U/g;
print "$RNA\n";
exit;