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

PHP Mysql LM - Exp Number - 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

PHP Mysql LM - Exp Number - 5

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

G.S.

Mandal’s,
Marathwada Institute of Technology, Aurangabad
Department of Computer Applications
PRACTICAL - LAB MANAUL
CLASS : FY-MCA- 2021-22 PART-II SUBJECT : PHP MySql Lab

LIST OF EXPERIMENTS
1. Program based on HTML tags (text formatting, images, font, hyperlink, list and

tables)

2. Program based on CSS (Inline, Internal and External CSS) , css properties for

position, text, font, borders, margin, padding, color, shadow, images.

3. Program based on HTML form elements using Bootstrap.

4. Program based on PHP variables, Decisions and loops.

5. Program based on different types of Arrays in PHP.

6. Program based on Form Validation through regular expression.(phone number and

email validations)

7. Program based on Functions (Simple and Parameterized Functions, Function call

by values and references, Optional parameter, Return statement, Recursion)

8. Demonstration on Database and table, relationships using MYSql.

9. Program based on Database connectivity though PHP and MYSql.

10. Program based on Insert, Select, Update and Delete operations on database tables.

MIT/FYMCA/LM/PHPMySql/2021-22/05 Prepared By : Dr. Chintal. P. L 1|P age


G.S.Mandal’s,
Marathwada Institute of Technology, Aurangabad
Department of Computer Applications
PRACTICAL - LAB MANAUL
CLASS : FY-MCA- 2021-22 PART-II SUBJECT : PHP MySql Lab

Lab Exercise Number: 05


Title of the exercise : Program based on different types of Arrays in PHP.

Array in PHP
 An array stores multiple values in one single variable
 In PHP, there are three kinds of arrays:
 Numeric array
 Associative array
 Multidimensional array

Numeric Array in PHP


 Numeric array is an array with a numeric index

Numeric Array Example


<html>
<head> <title> Numeric Array – Indexed Array </title></head>
<body>
<?php
$values=array(30,"Shailendra",45.56,45,35,78,"Sharma");
echo "<pre>";
print_r($values);
$cnt=count($values);
echo "Total number of items in array is :".$cnt;
echo "<br><br>";
echo "<ul>";
for($i=0;$i<$cnt;$i++)
{
echo "<li>".$values[$i]."</li>";
}
echo "</ul>";
?>
<body>
</html>

MIT/FYMCA/LM/PHPMySql/2021-22/05 Prepared By : Dr. Chintal. P. L 2|P age


G.S.Mandal’s,
Marathwada Institute of Technology, Aurangabad
Department of Computer Applications
PRACTICAL - LAB MANAUL
CLASS : FY-MCA- 2021-22 PART-II SUBJECT : PHP MySql Lab

OUTPUT of the above given Example is as follows:


Array
(
[0] => 30
[1] => Shailendra
[2] => 45.56
[3] => 45
[4] => 35
[5] => 78
[6] => Sharma
)
Total number of items in array is :7

 30
 Shailendra
 45.56
 45
 35
 78
 Sharma

MIT/FYMCA/LM/PHPMySql/2021-22/05 Prepared By : Dr. Chintal. P. L 3|P age


G.S.Mandal’s,
Marathwada Institute of Technology, Aurangabad
Department of Computer Applications
PRACTICAL - LAB MANAUL
CLASS : FY-MCA- 2021-22 PART-II SUBJECT : PHP MySql Lab

Associative array in PHP


 Associative array is an array where each ID key is associated with a value

Associative array Example


<html>
<body>
<?php

$marks=array(
"Adity"=>50,
"Ashwini"=>56,
"Govind"=>78,
"Shailendra"=>90
);

echo "<pre>";
print_r($marks);

foreach($marks as $xyz)
{
echo $xyz."<br>";
}

?>
</body>
</html>

OUTPUT of the above given Example is as follows:

Array
(
[Adity] => 50
[Ashwini] => 56
[Govind] => 78
[Shailendra] => 90
)

50
56
78
90

MIT/FYMCA/LM/PHPMySql/2021-22/05 Prepared By : Dr. Chintal. P. L 4|P age


G.S.Mandal’s,
Marathwada Institute of Technology, Aurangabad
Department of Computer Applications
PRACTICAL - LAB MANAUL
CLASS : FY-MCA- 2021-22 PART-II SUBJECT : PHP MySql Lab

Multidimensional array in PHP


 Multidimensional array is an array containing one or more arrays

Multidimensional array Example


<html>
<body>
<?php
/* Here $marks is an array, where ramesh, ganesh and harish
are the ID key which indicates rows and points to array which
have column values. */
$marks =
Array
(
"ramesh" => array("physics"=>50,"chemistry"=>40,"Maths"=>60),
"ganesh" => array("physics"=>90,"chemistry"=>10,"Maths"=>80),
"harish" => array("physics"=>34,"chemistry"=>57,"Maths"=>30),
);echo '<pre>';

foreach($marks as $nm=>$mrk)
{
echo 'Name :'.$nm;
foreach($mrk as $m=>$m1)
{
echo " $m:$m1";
}
echo "<br>";
}?>
</body>
</html>

OUTPUT of the above given Example is as follows:

Name :ramesh physics:50 chemistry:40 Maths:60


Name :ganesh physics:90 chemistry:10 Maths:80
Name :harish physics:34 chemistry:57 Maths:30

MIT/FYMCA/LM/PHPMySql/2021-22/05 Prepared By : Dr. Chintal. P. L 5|P age

You might also like