0% found this document useful (0 votes)
13 views

PHP Mannual Final

Uploaded by

tulasidevibtech
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

PHP Mannual Final

Uploaded by

tulasidevibtech
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

EX NO: 1

ARRAY OPERATION PAGE NO:


DATE:

AIM:
To write a Array function using php coding.

PROCEDURE:
Step 1: To open a notepad and write a html with php script coding.

Step 2: To assign a String using Array

$a1=array(“a red” ,”b green” ,”c orange”)

$a2=array(“a blue” ,”b green” ,”c black” ,”d rose”)

Step 3: To check the String match and print the screen $result=array.diff($a1,$a2)

Step 4: To declare the value of $cars in array.

Step 5: To this function in sort in string $c length+count($cars).

Step 6: To save the program and location[c:\wamp\www\filename.php]

Step 7: To run program (To open and start the wamp server];

1)to select the start the start all services localhost

2)localhost/filename.php

Step 8: End of the program.


PROGRAM:

<html>

<head>

<title>String manipulation</title>

</head>

<body>

<h1>array function<br>**********************<br>String
matching<br>*******************<br></h1>

<?php

$a1=array(“a””red, “b””green, ”c”” orange” ,”d””rose”)

$a2=array(“a””blue”, “b”“green”, “c””black”, “d” ”rose”)

$result=array_diff($a1,$a2);

print_r($result);

echo”<br>;

echo”**********************;

echo”<br>;

$cars=array(“c”,”php”,”java”,”c++”);

sort($cars);

$length=count($cars);

for($x=0;$x&lt;$length;$x++)

Echo$cars[$x];

For($x=0;$x<$length;$x++)

echo$cars[$x];

Echo”<br>”;
echo”combination of string”;

echo”<br>”;

echo***********************”;

echo”<br>”;

$frame=array(“kiruthi”,”devi”,”viji”);

$age=array(“10”,”7”,”8”);

Echo”<br>”;

$c=array_combine($frame,$age);

print_r($c);

?>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is execute clearly and the output is verified.
EX NO: 2
FACTORIAL USING IF PAGE NO:
DATE: ELSE

AIM:
To write a java program to find factorial of a given number.

ALGORITHM:
Step 1: Start the program.

Step 2: Import the java packages.

Step 3: Declare the class and classname.

Step 4: Create a member function getdata() to print p and get the input number.

Step 5: Create another member function calfact() using to find factorial of a given number.

Step 6: In the member function calfact() using forloop for number of iteration and then print

the result.

Step 7: Create another class fact pgm to create an object.

Step 8: Using the object to call the member functions getdata() and calfact() to print the

result.

Step 9: Stop the program.


PROGRAM:
<html>

<head>

<title>Factorial number</title>

<body>

<h1>factorial number<br>

<h1>****************<br>

enter the factorial value:

<form>

<input type="text box"name="n"/>

</form>

<?php

if(isset($_GET['n']))

$n=$_GET['n'];

$mult=1;

while($n>0)

$mult=$mult*$n;

$n=$n-1;

echo"result";

echo$mult;

?>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO:3
INVENTORY CONTROL PAGE NO:
DATE:

AIM:
To display a inventory control using php coding.

PROCEDURE:
Step 1: To open the notepad and write a php script coding.

Step 2: To get the input value from user using text box in form.

Step 3: To assign a string using array

$item=array(“m1”array(“fruit””apple””price””200”,”quantity””2kg”)

Step 4: print the value of 1 data set count.

To check the condition

For each($ item as $ each item)

Itm $i;

If($i==$f)it is
true

}
PROGRAM:
<html>

<head>

<title>inventory control</title>

</head>

<body>

<form method=”POST”>

Enter item number<input>

Type=”text”name=”name/>

<input

type=”submit”id=”submit”value=”submit”/>

</form>

<table border=‟5‟>

<?php>

$item=array(„m1”array(“fruit””apple”,”price””200”,”quantity””2kg”),”m2”array
(“vegetable””carrot”,”price””50”,”quntity””1kg”),);

$dataSetCount=count($item);

echo”<tr><td>”;

echo”<h1>therare$dataSetCount

items</h1>”;

echo”</td></tr>”;

$i=0;

Foreach($item as $each_item)

$i++;

echo”<tr><td>”;

echo”<h2>item$i</h2>”;
echo”</td></tr>”;

if($1==$f)

foreach($each_item as $key=>$val)

echo”<tr><td>”; echo”<b>$key</b>”.”/t”.

$val.”<br/>”; echo”</td></tr>”;

}
}

</table>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO:4
STUDENT TABLE USING PAGE NO:
DATE: KEY AND VALUE

AIM:
To write a student mark list using php coding.

PROCEDURE:
Step 1: To Write a student mark list using php coding.

Step 2: To get the value from using textbox in form.

Step 3: To assing a string using array.

$rno=array(“21”array(“name””vijithiga”,”m1””38”.”m2””54”,”m3””8”,
”total””178”,”average””53.6”

Step 4: print the range of $datasetcount.

Step 5: For each($roll no as $each_roll no)

roll no $i;

if ($i==$f)if it is true

For each($each_roll no as $key$value)

Print $key$value

Step 6: To save the program&localhost c:\wamp\www\file name.php

Step 7: To run the program(to open and start the wamp server).

Step 8: To start the all serviceslocalhost.

Step 9: End the program.


PROGRAM:
<html>

<body>

<form method="post">

Enter student no:

<input type="text"name="n1">

<input type="submit"value="submit">

</form>

<table border='5'>

<?php

$f=$_POST['n'];

<?php

$Rollno=array("u1"array("name""uma","m1""75","m2""90","m3""100","total"
"265","average""88.3"),"u2"array("name"”ani","m1""75","m2""65","m3""100
","total""240","average""88.3);"u3"array("name""sim","m1","m2""100","m3""
100","total""300","average""100"),);

$dataSetcount=count($Rollno);

echo"<tr><center></td>";

echo"<tr><td>";

echo"<n1><b>APC collage</b></h1>";

echo"</td></center></tr>";

echo"<tr><td>";

echo"<n1>student mark list</n>";

echo"</td></tr>;

$i=0;

for each($Rollno as $each_Rollno)

$i++;
echo"<tr><td>";

echo"<h2>Rollno$1</h2>";

echo"</td></tr>;

if($i==$f)

for each($each_Rollno as $key=>$val)

echo"<tr><td>"; echo"<b>$key</b>"."/t".

$val."<br/>"; echo"</td></tr>";

?>

</table>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX.NO:5
USER DEFINED FUNCTION PAGE NO:
DATE:

AIM:
To perform the user defined functions using php coding.

PROCEDURE:
Step 1: To open the notepad and write a html using php script coding.

Step 2: To get the array from the user.

Step 3: To perform the user defined functions such as function without input argument and

return no Value and functio with default argument…

Step 4: Then print the result with above user defined functions.

Step 5: End of the program.


PROGRAM:
<?php

$x=25;

$y=45;

title3(“Addition of $x+default value&quot;.br());

$res=”Result.add($x).br();

echo”<b>$res</b>”

title3(“Addition of $x+$y”.br());

echo(“Result.add($x,$y).br());

title3(“Addition of default a + default b”.br());

echo(“Result”.add().br());

Function add($a=5,$b=10)

return $a+$b;

function title3($msg)

Echo”<h3>”.$msg.‟</h3>;

Function bo($msg)

Return”<br>”$msg”</b>”;

}
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 6
FACTORIAL USING RECURSION PAGE NO:
DATE:

AIM:
To find the factorial using recursion in php coding.

PROCEDURE:
Step 1: Start the program.

Step 2: Import the java packages.

Step 3: Declare the class and classname.

Step 4: Create a member function getdata() to print p and get the input number.

Step 5: Create another member function calfact() using to find factorial of a given number.

Step 6: In the member function calfact() using forloop for number of iteration and then

print the result.

Step 7: Create another class fact pgm to create an object.

Step 8: Using the object to call the member functions getdata() and calfact() to print the

result.

Step 9: Stop the program.


PROGRAM:
<html>

<head>

<title>Factorial</title>

</head>

<body><h1><b><u>FACTORIAL USING RECURSION</u></b></h1>

</body>

<form>

Enter The n value

<input type="text box"name="n"/n><br>

<input type="submit"value="check the sum"><br>

</form>

<?php

if(isset($_GET['n']));

$n1=$_GET['n'];

function Factorial($n1)

if($n1==0)

return 1;

else

return $n1*Factorial($n1-1);

}
}

echo Factorial ($n1);

?>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 7
NCR USING FACTORIAL PAGE NO:
DATE:

AIM:
To find the NCR using factorial command in php coding.

PROCEDURE:
Step 1: To open a notepad and write a html using php script coding.

Step 2: To get the value of n,r using text box.

Step 3: To define a function

Function ncr($n,$r)

$c=text($n)/fact($r)*fact($n-$r);

Return $e;

Function fact($n1)

$f=1;

For($i=1,$ic=$n;$i++)

$f=$f*fi
;

Return f;

Step 4: Print the f value.

Step 5: To call the function echo ncr($n,$r)


Step 6: To save the program and location[c:\wamp\filename.php].

Step 7: To run the program(To open and start the wamp server];

2)localhost/filename.php

Step 8: End of the program.


PROGRAM:
<html>

<head>ncr</head>

<title></title>

<body>

<h1><u><ncr USING FACTORIAL </u></h1>

</body>

<form>

Enter The n value:<br><input type="text box"name="n"/><br>

Enter The r value:<br><input type="text box"name="r"/><br>

<input type="Submit"value="Check"/>

</form>

<?php

if(isset ($_GET ['n'])&& isset($_GET['r']))

$n=$_GET['n'];

$r=$_GET['r'];

function ncr($n1,$r1)

$c=fact($n1)/(fact($r1)*fact($n1-$r1));

return $c;

function fact($n1)

$f=1;

for($i=1;$i<=$n1;$i++)
{

$f=$f*$i;

return $f;

echo ncr($n,$r);

?>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output was verified.
EX.NO:8
STRING MANIPULATION PAGE NO:
DATE:

AIM:
To display current date and time using php coding..

PROCEDURE:
Step 1: To open a notepad and write a html using php script

coding. Step 2: To write a php coding echo date(y/m/d) echo

time(“H:i:s”); Step 3: To display the current date and time.

Step 4: To save the program and location[c:\wamp\www\filename.

Step 5: To run the program(To open and select the wamp

server) 1)To select the start services localhost.

2)localhost/filename.php.

Step 6: End of the program.


PROGRAM:
<?php

//date_default_timezone_set(„Asia/Calcutta‟);-You can choose any timezone

//Calculate 60 days in the future

//seconds*minutes*hours*days+current time

$inTwoMonths=60*60*24*60+time();

Setcookie(„lastVisit‟,date(“G:i-m/d/y”),$inTwoMonths);

If(isset($_COOKIE[„lastVisit‟]))

$visit=$_COOKIE[„lastVisit‟];

echo”Your last visit was-“.$visit;

else

echo”You‟ve got some stale cookiest!”;

?>

</body>

</html>
OUTPUT:

RESULT:
Thus the above program is executed clearly and the output is verified.
EX NO: 9
PERSONAL DETAIL FILE PAGE NO:
DATE:

AIM:
To process personal details using file in php coding.

PROCEDURE:
Step 1: To open a notepad and write php script coding.

Step 2: To get a value using textbox.

Step 3: To create a file name by add_emp.txt.

Step 4: Usingf open to open a file.

Step 5: To print fruits name using $output.

Step 6: Using f write to print the file.

Step 7: To save the program and location[c:\wamp\www file name.php].

Step 8: To run the program(To open and start all server)

(i)To select the start all serviceslocalhost

(ii) localhost filename.php.

Step 9: End the program.


PROGRAM:
<html>

<body>

<form action="" method="POST">

<H1>Biodata</h1>

Name:<input type=text name="name1"><br><br>

Address: <textarea name=address> </textarea><br><br>

Age: <input type=text name=age><br><br>

Phone: <input type=text name=phone><br><br>

Email: <input type=text name=email><br><br>

Educational Qualification:<input type=text name=qualification><br>

<input type=submit value=Display><br><br>

</form>

</body>

</html>

<?php

if ($_POST) {

echo "<h1>Biodata</h1>";

echo "Name: " . $_POST["name1"] . "<br>";

echo "Address: " . $_POST["address"] . "<br>";

echo "Age: " . $_POST["age"] . "<br>";

echo "Mobile: " . $_POST["phone"] . "<br>";

echo "Email: " . $_POST["email"] . "<br>";

echo "Qualification: " . $_POST["qualification"] . "<br>";

?>
OUTPUT:

RESULT:
Thus the above program was executed and the output was verified.
EX.NO:10 STUDENT MARK DATA
DATE: BASE PAGE NO:
USING HTML FORM

AIM:
To display student mark data in html using php coding.

PROCEDURE:
Step 1 : Open the notepad and write a html with php script coding.

Step 2 : Assign a string using array.

Step 3 : Print the range of $dataset Count

Step 4 : Check the condition.

Step 5 : Save the program.

Step 6 : Run the program.

Step 7 : End the program.


PROGRAM:
<!DOCTYPE html>

<html>

<head>

<title>Insert Page page</title>

</head>

<body>

<center>

<?php

// servername => localhost

// username => apc

// password => empty

// database name => college

$conn = mysqli_connect("localhost", "root", "", "college");

// Check connection

if($conn === false){

die("ERROR: Could not connect. "

. mysqli_connect_error());

// Taking all 5 values from the form data(input)

$name = $_REQUEST['name'];

$email = $_REQUEST['email'];

$mobile = $_REQUEST['mobile'];
$date = $_REQUEST['date'];

// Performing insert query execution

// here our table name is college

$sql = "INSERT INTO apc VALUES ('$name',

'$email','$mobile','$date')";

if(mysqli_query($conn, $sql)){

echo "<h3>data stored in a database successfully."

. " Please browse your localhost php my admin"

. " to view the updated data</h3>";

echo nl2br("\n$name\n $email\n "

. "$mobile\n $date");

} else{

echo "ERROR: Hush! Sorry $sql. "

. mysqli_error($conn);

// Close connection

mysqli_close($conn);

?>

</center>

</body>

</html>
OUTPUT:
RESULT:
Thus the above program is executed clearly and the output verified.

You might also like