0% found this document useful (0 votes)
7 views25 pages

PHP and MySQL Programs and MQP

The document provides a series of PHP scripts for various programming exercises, including printing 'Hello World', checking odd/even numbers, finding the maximum of three numbers, swapping two numbers, calculating factorials, checking for palindromes, reversing numbers, generating Fibonacci series, and implementing string functions. It also covers array manipulation, constructors and destructors, form handling using GET and POST methods, checking for prime numbers, and matrix addition. Each script includes code snippets and expected output for clarity.

Uploaded by

ajay123456ab
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)
7 views25 pages

PHP and MySQL Programs and MQP

The document provides a series of PHP scripts for various programming exercises, including printing 'Hello World', checking odd/even numbers, finding the maximum of three numbers, swapping two numbers, calculating factorials, checking for palindromes, reversing numbers, generating Fibonacci series, and implementing string functions. It also covers array manipulation, constructors and destructors, form handling using GET and POST methods, checking for prime numbers, and matrix addition. Each script includes code snippets and expected output for clarity.

Uploaded by

ajay123456ab
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/ 25

APPENDIX -A

DSC17-Lab: PHP and MySQL Lab

Write a
PHP script to print hello world'.

Labl.php
<?php
1/Program to print Hello World
echo "Hello World";
?>

Output
Hello World

) Write a PHP script to find odd or even number from given number.
Lab2.php
<?php
I/ Program to check Odd or
Even number
Sn=5;
echo *Given number is
$n"."<br;
if ($n%2==1)
echo $n is Odd number";
else 0C=d
echo "$n is Even number";
?>

Output
Given number is 5
5 is Odd number
3.
Write a PHP script to find maximum of three numbers.

Lab3.php
<?php
/ Program to find maximum of three numbers
=
$a 10;
=
$b 20;
=
Sc 30;
echo "Given numbers are :""<br>";
echo a-$a""<br>";
echo "b=$b""<br>";
echo c=$c""<br>";
PHP &MYSOL
184

if ($a>$b)&& ($a>$c))
echo "$a is largest number","<br>":
else if (($b>$a) && ($b>$c))dodte
'<br>";
echo "$b is largest number",
else if (($c>$a) &&
($c>$b))
"$c is largest number", "<br>";
echo
else

echo Numbers are equal";


?>
Output
Given numbers are :
a=20
b=10
C=30
30 is largest number

4. Write a PHP script to swap two numbers.


Lab4.php
<?php
/ Program to swap two numbers
$a 10=
$b 20;=
echo "Before Swapping""<br>";
echo a=$a""<br>";
echo "b=$b""<br>":
$t=$a;
Sa-$b;
$b=$t;
echo "Before Swapping""<br>";
echo "a-$a""<br>";
echo b=$b""<br":
?>
Output
Before Swapping
a=10
b=20 08
Before Swapping
a-20
b=10
185
HsMANUAL
to find the factorial
Write
aPHP script of a
number.oi
Lab5.php
<?php
UIProgram to find factorial of a number0 ETO
Sn=5;
echo Given number is $n""<br>".
Sf=1;
for ($i=1;$i<=$n;$it+)

$f-$f*$i; (0-ncolinl

echo Factorial of $n is $f";


?>

Output
Given number is 5
Factorialof 5 is 120
Write a PHP script to check whether given
number is palindrome or not.
Lab6.php
<?php
1/Program to check given number is palindrome or not
Sn=353;
Sx=$n;
$s=0;
while ($n!=0)
{
Sr=Sn%10;
Ss=$s*10+Sr;
Sn=(int)($n/10); eodi noito

if($x==$s)
echo "$x is palindrome number"."<br>";
else
echo "$x is not a palindrome number"."<br>";
?>
Output
palindrome number
PHP &
MYSOI
186
a given number and calculate
its
to reverse sum.
7. Write a PHP script Lab7.php

and Sum
<?php
Reverse a given number calculate
to
/ Program

$n=972;
$x=$n;
number is $n"'<br>":
echo "Given
Srev=0;
$sum-0;
while ($n!=0)

Sr=$n%10;
Srev=$rev* 10+$r;
$sum=$sum+$r;
Sn=(int) (Sn/10);
09ta2to isio
echo "Reverse of $x is $rev""<br":
echo "Sum of $x is $sum";ch lao o ibeoe
?>
Output

Given number is 972 de


Reverse of 972 is 279
Sum of 972 is 18
using Recursivefunction
8. Write a PHP script to to generate a Fibonacci series
Lab8.php
<?php
/ Program for fibonacci series 01

function fibo($n,$a-0, $b=1)


{
if(Sn==0)
{
return;

echo $a."<br>";
$c =$a +$b;
fibo(Sn- 1, $b, Sc);

Sn =5;
echo "Given input value is:$n""<br>;
echo "Fibonacci Series are:"."<br>;
MANUAL
LAB 187
|fibo($n);
?>

Output
Given input value is:5
Fibonacci Series are:

2
3

Write a PHP script to implement at least seven string functions.


9.

Lab9.php
<?php
/Program for string functions
Sstr ="COMPUTERscience";
echo "1. Lengthof the string is: ". strlen ($str)."<br>";iotA
echo 2.Reverse String:".strrev($str)."'<br>'";
echo "3. Number of words in the string
are: ".str_word_count($str)."<br":
echo 4.Upper Case of the given string is:".
strtoupper($str)."<br>";
echo "5.Lower Case of the given string
is:". strtolower($str)."<br>";
echo "6. Converts first letter
of every word in the string to
uppercase:".
ucwords($str)."<br>";
echo "7.Position of 'Science'in string is: ".strpos($str, 'science'),"<br>";
nctiot
?>

Output
1. Length of the string is: 16
2. Reverse String: ecneics RETUPMOC
3. Number of words the string are: 2
in
4. Upper Case of the given string is:COMPUTER SCIENCE
5. Lower Case of the given string
is:computer science
0. Converts first letter of every word in the string to
uppercase:COMPUTER
Science

Position of 'science'in string is:9


7.
10.
Write a
PHP program to insert new item in array on any position in PHP.

Lab10.php
<?php
/Program to insert new item in an array
Slist =array(10,20,30,40,50); oMod
PHP &MYSOL
188

'Original
array is:."<br>";
echo
foreach ($list as
$i)

echo "$i""
"

$item =35;
3, 0, $item);
array_splice($list,
$item the array is:""<brs".
echo <br>"."After inserting
foreach ($list as $i)
{
echo "$i"" ";

?>
Output

Original array is:

10 20 30 40 50
35 the array
After inserting is:

10 20 3035 40 50
and destructor.
11. Write a PHP scriptto implement constructor
Labll.php

<?php
I/ Constructorand Destructor

class laptop

{
var Scompany;
var $model;
var Sprice;
function construct ($x, $y, $z)

echo "Constructor"."<br>";
echo *=== ===""<br";o
$this->company=$x;
Sthis->model=$y;
$this->price=$z;

function display)iet
{
echo "Company name =Sthis->company""<br>";
echo Model number-$this->model""<br>";
echo "Price=$this->price""<br";
LAB MANUAL

189
function
destruct()
{
echo
echo <br>""Destructor""'<br>".
echo "Destroying
"<br;
echo "Destroying .$this->company."<br>";
$this->model."<br":
echo "Destroying .$this->price."<br";

Sob=new laptop(“Dell",
4455","35000");
$ob->display(); aolo
?>

Output
Constructor

Company name =Dell


Model number=4455
Price=35000

Destructor

Destroying Dell
Destroying 4455
Destroying 35000
12.
Write a PHP script to
imnplement form handling using
get method.
Lab12.php
<html>
<body>
<h2>Using GET Method</h2>
<form method=GET
Name:<input type="text" name=Uname"> <br
Password: <input type='password"
name="Pword'> <br>
<inputtype='submit name="sub' value=Login'">
<form>

cCbbors T20ethS
<?php 209sborttom o

if(isset($_GET['sub'|)

|Sname=$_GET[Uname"]:
PHP&
MYSOI

190
Pword"l;
Spassword=$_GET[ && Spassword== Welcomne@123")

if ($name=="Department"
Successful"."<br>";
echo Login
Password'':
Username or
else

echo "Invalid

?>
</body>
</html>

Output
Login button:
Before selecting
c
localhost
X 3(8) What

O localhost/lab12.php

Using GET Method


Name: Department
Password:

Login

After selecting Login button:


3 localhost X 9 (8)What
X

O localhost/lab1 2.php?Uname..

Using GET Method


Name:
Password:

Login

|Login Successful

method
form handling using post
13. Write a PHP script to implement
Labl3.php
<html>
<body>
<h2>Using POST MethodK/h2>
<form method=POST"
Name: <input type='text" name="Uname"> <br
191
LABMANUAL

type="password" name=Pword"'>
Password: <input <br>
name= 'sub"
<input type="submit value="Login">
</form>

<?php bod
:isset($ POST['sub )) soooof megoced
{
Sname=$_ POST["Uname"];:goomd
Spassword-$_ POST["Pword"];odu
if (Sname==Department" && Spassword=="Welcome @123")
echo Login Successful'""<brs":
else
echo "InvalidUsername or Password";

?>
<body>
<html>
Output
Before selecting Login button:
co lo x 9(12) V wsr PHPA X

O localhost/Mab13.php

Using POST Method


Name: Department
Password:
Login

After selecting Login button:


9 Vw3r
(12) PHP
X

localhost/lab13.php

Using POST Method


Name:
Password:
Login

Login Successful
PHP &
MYSQL
192
the
form input by method post to
4. Write a PHP scriptthat receives checkthe

is prime or
not
number Lab14.php

<html>
<body>
prime number or not</h3>
<h3>Program to check
<form method='POST"'>
type="text name="prime"> <br><br>
Name: <input
name='sub value="Submit>
<input type='submit"
</form>
<?php
if(isset($_POST['sub'|)

Sn=$_POST["prime"]:
Sc=0;
for($i=1;$i<=$n;$i++)

if(Sn%$i=-0)
Sc++;

if (Sc==2)
echo "$n is a Prime Number""<br>";
else
echo "$n is not a Prime Number" "<br>":

?>
</body>
</html>
Output:
Before selecting Submit button:
X
localhost/lab14.php

O localhost/lab14.php

Program to check prime number or not

Name:7

Submit
193

MANUAL
LAB button:
Submit 14.php
selecting CO localhost/lab

After
O localhost/lab14.php

not
prime number or
Program tocheck

Name:

Submit

7is a Prime Number

that receive string as a form input


Write a PHP script Labl5.php

<html>
<body>
string as a form input</h3>Ct
<h3>Program to receive
<form method="POST"'>
Name: <input type=*text"
name="input'> <br><br>O
<inputtype='submit" name='sub" value='Submit">
<form>

<?php
if(isset($_POST['sub']))

Sn=$_POST[input"];
echo Name of the Department is $n";

</body>
</html>

Output:
Before selecting Submit button:
X
co localhost/lab15,php

O localhost/lab15.php

Program to receive string as a form input

Name:Computer Science

Submit
194 PHP &
MYSOL

After selecting Submit button:


3 localhost/lab15.php

O localhost/lab15.php

...
as a form input
Program to receive string

Name:

Submit

Name of the Department is Computer


Science

a PHP script tocompute addition of twomatrices as a form inn.


16. Write

<?php
|/ Addition of two Matrices
if(isset($_POST[´Addition' |))s nnit eb siooTSOol
Srows=$_POST['rows']1:
Scols=$_POST['cols'];
SA=S_POST['A]:
$B=$_POST['B';
$C=0;
for($i=0;$i<$rows;$it+)
{
for(Sj=0;Sj<$cols:$j++)

SC[$i][Sj]=$A[$iJ[Sj]+$B[$i]ISj];

}
echo <h2>Matrix A B:</h2>"; +
echo <Ktable border=°1'";
for($i=0;$i<$rows;$i++)

echo *<t>":
for(Sj-0:$j<$cols;$j++)
{
echo<td>".$C[$iJ[$j]"</td>";
}
echo</r>";
}
echo <K/table>:
return;
MANUAI
LAB 195

<html>
<body>
ch3>Enter Rows and Columns</h3>
<form method="POST">
Rows:<input type='number
name='rows" required>
Columns:<input type="nuBer name="cols required'>
innuttype="'submit" name="dimension" value-"Submit'>
<form>
<body>
<html>

<php
if(isset($_POST['dimension'
|))

Srows=$_POST['rOws' };
Scols=$_POST['cols'];
echo "<h3>Enter Matrices</h3>":
echo <form method='POST'>;
echo <input type=hidden' name='rows' value=Srows>";
echo "<inputtypehidden' name='cols' value='Scols'>";
echo <h3>Matrix A</h3>";

for(Si-0;$i<$rows;$i++)

for(Sj-0:$j<$cols;$jt)

ccho "<inputtype='number name='A[$i][$;]'required>";

echo <br>":

echo <h3>Matrix B</h3>";


for($i=0;$i<$rows;$it+)

for(Sj=0;$j<$cols:$j++)

echo <input type='number' name=B[$i][$jT" required>";

echo
<br>";
196 PHP &
MYSOL

echo <br>";
echo <input type='submit' name='Addition' value='Addition'.
echo </form>";
}
?>

Output
localhost/lab16,php X

O localhost/lab16.php

Enter Rows and Columns

Rows 3 Columns3 Submit

EnterMatrices

Matrix A
3 3 3
3 3

3 3

MatrixB

2 2
2
Addition

3 localhost/lab16.php X

O localhost/lab16.php

MatrixAt B:ArOsL q

5|5|5

17. Write a PHP script to show the functionality of date and time function.

Lab17.php
<?php
echo Date and Time Functions""'<br>";
echo = "<br>";

Scurdate= date(d-m-Y"):;
197
LAB
MANUAI

Techo Current Date:".$curdate."<br>":

Scurtime= time();
echo "Current Time:".(date("h:i:s",Scurtime),"<br>".

sdate=nevw DateTime(15-04-2024');e 1ao


Sdate->add(new Datelnterval("PSD')):
echo Date Add Days:".$date->format('d/m/Y'),"'<br>";

Sdatel=new DateTime(“15-04-2024');goheols
Sdate2=new DateTime("20-04-2024');i bebsolquiovoej
$x=$datel->dif(Sdate2);ikoteeoo bobsolgUalr
echo Date Difference :".Sx->format("%R%a days')."<br>";
bosg o belioe
Sdate=new DateTime(15-04-2024');
Sdate->modify('+5 days');
echo "DateModify:".$date->format('d-m-Y')"<br>"; bod

Sdate=new DateTime(“01-05-2024');
Sx=new Datelnterval('P5D');noiud oliH bsolaU atoaka
Sdate->sub($x);
echo "Date Subtraction:".$date->format('d-m-Y),"<br>";
echo : <br>":
?>

Output
Date and Time Functions

CurrentDate:10-05-2024
CurrentTime:09:28:33
Date Add Days:20/04/2024
Date Diference :+5 days
Date Modify:20-04-2024

.Writea
Date
Subtraction:26-04-2024etaot

PHP program to upload a file.


o

Lab18.php
<html>

<body>

<h3>Program to Upload a File </h3>


<form
method'post" enctype='multipart/form-data">
198 PHP &MYSQL

name=*file" id='Gle
Select a file to upload: <input type="file"
File name='sub'>
<input type="submit" value="Upload
</form>

<?php
if (isset($_POST['sub' ]))

$file-$_FILES['file']['name ]:
$flename=$_FILES['fle ]['tmp_name'];

Supload='c:l\xampp\l";
$file)
if(move_uploaded_file($flename, Supload.
echo "File Uploaded Successfully";
else

echo Failed to Uplaod a file";

?>
</body>e
</html>
Output:
Before selecting Upload File button:
3 localhost/lab18.php

O localhost/lab18.php

Program to Upload a File

Select a file to upload:Choose File Database php Upload File

After selecting Upload File button:


E localhost/lab18.php

O localhost/lab18.php

Program to Upload a File05-O


Select a file to upload: Choose File No file chosen Upload File

File Uploaded Successfully

ybo
MANUAL
LAB
199
a PHP script to implement database
Write
19 create the database creation. (The
used to "College") following
program
Lab19.php
<?php
I/Program for
database creation
$host ="localhost":
Susername
Spassword =
="root;i ioDatovhsstds
ofd
Sconn new = mysqli($host,
Ssql="use college"; $username, $password);

Sresult-$conn->query ($sql);
if (Sresult
==0) iutaesoone bstse

$sql="create database
a-g college";
Sresult-Sconn->query ($sql):
ho if(Sresult) notsoileqsaldstorii
bhonecho "Database Created oitsoiloosolde
rob else Successfully'","<br>";
0h
echo "Could not
Create Database"
"<br>";
else

echo Database Already


?> Exits'""<br>";

Output
Database Created
20. Successfully
Write a
PHP script to create table. (The
Dle "Staff
using the following program used to create the
database college" in
MySQL.
php Lab20.php
Program for
Shost
table
creation
oqo
Susername
=localhost";
=
Spassword
root";
=.
Sdbname='college";
Sconn=
new
Ssql="use mysqli(Shost,$username, Spassword);
$dbname:
if
(Sresult
==0)
Sresult-$conn->>query($sql):
echo eogo2.ot.&ola nolq
else Database
Does not obA3EADEosiay ooiiqo

exits."<br>;ouls OLG
200 PHP &
MYSQL

$sql="createtable staff(Staff _id int primary key, Staff name


float(8,2))"; varchar(20),Salary

Sresult=$conn->query($sql):
if($result)

echo "Table Created Successfully"."<br>";


else
echo Table already exits /Could not Create Table""<br>";

?>
Output
Table Created Successfully
21. Develop a PHP program to design a college admission form using MYSOr
database.

Create thetable "application"using the database "college" in MySQL as follows

create table application (sname varchar(20), fname varchar(20), mname


varchar(20),dob date, gender varchar(10),email varchar(25),
mobile int, addres
varchar(40), cname varchar(25),percen float(5,2), course varchar( 10));

Lab2la.html
<html>
<body>
<h2>College Application Form</h2>
<form action="lab20b.php" method=POST">
Name of the Student:<input type="text name="sname" required> <br><br
Father'sName: <input type-"text" namne="fname" required> <br><br>
ad Mothers's Name: <input type='text" name="'mname" required> <br><br>
Date of Birth:<input type="date" name-"dob" required> <br><br>
Gender:<select name="gender">
<option value="Male"> Male </option>
<option value-"Female"> Female </option>
</select> <br><br>
Email:<input type="email" name-"'email" required> <br><br
Mobile:<input type="text" name='mobile" required> <br><br>
Address:<textarea name="address" required> </extarea><br><br
PUC Name: <input type=" text" name='cname" required> <br><br
Collage
PUC Percentage: <input type="text" name="percen" required> <br><br>
Course Applied:<selectname="course">
<option value-"B.Sc">B.Sc</option>
<option value="BCA'>BCA</option>
<option value="B.Com">B.Comslontion0agp
</select> <br><br>
MANUAL 201
LAB
"submit" name="sub'" value="Submit'>
type=" <br><br>
|<input
</form>
<body>
</html>

Lab2lb.php

<html>

<?php
if(isset($_POST['sub'))

=localhost":
Shost

Susername =root':
=
|Spassword
Sdbname="college";
Ssname=S_POST[“'sname");
Sfname=$_POST[“fname"];

Smname-$_ POST["mname"];
Sdob=$_POST["dob'"];
Sgender=$_POST['gender"]:
Semail=$_POST[“email'];
Smobile=$_POST["mobile;
Saddress=$_POST["address"];
|Scname-$_POST[“cname"];
Spercen=$_POST[percen'"];
Scourse=$_POST["course"];
=
Sconn new mysqli($host,$username,$password,
$dbname);
Ssql="use Sdbname";
Sresult=$conn->query
($sql);
if
(Sresult ==0)
echo Database Does not exits"."<br>;
else

Ssql="insert into applicationvalues ("Ssname,'9$fname','


$mname,' $do
b';
Sgender'
Semail',Smobile, $address', ,'$cname,Spercen, Scourse' )";

|if(Sresult)
Sresult-$conn->query
($sq);
echo
"Record Inserted
else Successfully""<br>";
echo
"Could not insert record:"."<br>";

?>
PHP &
MYSQL
202

Output:
Submit button:
Before selecting localhost/lab20a.html

O localhost/lab20a.html

Form
CollegeApplication
James
Name of theStudent:

Father's Name:John

Mothers's Name:Jancy

Birth:e1/e1/ 2004
O
Date
of
Gender. Male

Email: [email protected]

Mobile:9988776655

KR Pura

Address. Bengaluru

College
PUC Collage Name: Govt. Pre University

98. 56
PUC Percentage:

Course Applied BCA v

Submit oldoa

After selecting Submit button: X


3 localhost//lab20b.php

O localhost//lab20b.php

Record Inserted Successfully


APPENDIX -C
QUESTION PAPER PATTERN (SAMPLE)
DSC17 :PHP & MySQL

The question paper pattern for theory paper has three sections.

Section-A:Contains 9questions, out of which a student has to answer 6 questions. Each


question carries 2marks (6 x 2=12).
Section-B: Contains 6 questions, out of which a student has to answer 4 questions. Each
question carries 6 marks (4 x6= 24).
Section-C: Contains S5 questions, out of which a student has to answer 3questions. Each
question carries 8 marks (3x 8 =24).
Number Section-A Section-B Section -C
SL.No Unit (8Marks)
of Hours (2 Marks) (6 Marks)

1Unit-I 08 2
08 2 2 1

2 Unit-II
3 Unit-II 10 2 1
1

4 Unit-IV 07 2 1
1

1
1

5 Unit-V 09 1

6 (Answer any 4) 5 (Answerany 3)


Total 42 9 (Answer any 6)
24 24
Marks 12
Total
PHP & MYSQL
226

Model Question Paper-I


VISemester BCA
DSC17: PHP MySQL Lab
Time: 2.30 Hours
&

:
Max.Marks 60

Section -A

(6x 2 =12)
I. Answer any six questions. Each question carries 2 marks.
1. What is PHP?

2. What are constant? Give an example.


3. What is if.else statement? Give its syntax.0nto
4. What is use of Require() function?
5. What is user defined functions?
oapo nioDo
Give an example
6. What is a string?Give an example.
7. Difference between class and object.ooarsoieascesloeDt
8. What is database?
9. What is MySQL client?

Section-B

6 marks. (4 x6= 24)


IL.Answer any four questions. Each question carries
10. Explain the features of PHP.
11. Explain switch statement with an example.
12. Write a note on array functions.
13.Explain any three string functionswith an example.
14. Write a note on database terms.
15. Write a note on MySQL commands.

Section-C

III. Answer any three questions. Each question carries 8 marks. (3x8 =24)
16. Explain data types with an example.
17. Discuss in detail multidimensional array with an example.
18. Write a note on:
i) Functions and variable scope.
ii) Recursive functions

19.Explain creating and accessing class and objects with an example.


20. Explain executing simple queries using PHP and MySQL.
MODEL QUESTION PAPERS
227
Model Question Paper-I|
VISemester BCA
DSC17: PHP & MySQL Lab
Time: 2.30 Hours

Section-A
Max.Marks 60:
I. Answer any 6
questions.Each
1. Write any question carries
two features of PHP. 2 markS.
2. What is
variable? Give an
(6x2= 24)
3.Write the
syntax for switch example.w S iD ebo
4. What statement.
is an array?
5. What Give an
a function?
is example.
6. Explain Give the syntax.
any two
7. What string
is an functions with an example.
8. What object? Give
istable? an example. iD
9. What is
phpMyAdmin?

IIL.
Answer any 4 questions. Section - B
10.Write a Each
note on
11.Write a
note on
data type. question carries 6
marks.
12.
Explain theuse
array
functions.
(4x6=24)
13. of
Explain any six Include() and
14.Write library Require)
thefeatures
15. of
functions with functions.eo
an example.
Explain MySQL.
connecting to
MySQL and
selectingthe
database.
M.Answer
16.Writeany 3 Section-C
questions. Each
a note on
17.Explain historyand question carries 8
18. any two featuresof marks.
Write anote
on:
looping PHP.Co
statements with
ExN (3x8=
i) 2A)
Functions and syntax and
ii) example.
Recursive variable
19. scope.
Explain functions
20. different
types of
Explain
MySQL inheritance
function with with an
an example.utot at s
example.
228 PHP & MYSQL

ModelQuestion Paper-11|
VI Semester BCA

DSC17: PHP & MySQL Lab


Time: 2.30Hours Max.Marks 60 :
. Answer any
1.
6 questions. Each
What is configurationin PHP?
Section-A

question carries

2. What are keywords? Give an example.


2 marks. (6x 2 =24)

3. What is while loop? Give its syntax.


4. What is the use of include()function.
5. Explain any two library functions with an example.
6. What is string?Give an example.
7. Differentiate between class and objects.
8. What is MySQL?
9. What is create commend? Give an example.

Section - B
IL. Answer any 4 questions. Each question
carries 6 marks. (4x6=24)
10. What is an expression? Explain with
example.
11. Explain any two if statements with syntax
12. Write a note on array functions.
and example.O5os
13. Explain any three date and time
functions with an example.
14.What is data type in MySQL?
Explain the numeric data type.
15. Write a note on MySQL functions.

Section -C
IIIL. Answer any 3 questions. Each question carries 8
16. Explain any four types of
operators with
marks. & =
(3 x 8 24)
17. Explain different types of example.oauo olon&o
arrays.
18. What is a function?
Explain creating and invoking
user defined function with an
example.
19. Explain types of
constructorswith an example.
20. a)Write the
features of
MySQL.
b) Updating Records usingPHP and MySQL.sbct02ta
SYLLABUS

BCA
DSC17 : PHP & MysQL
Course Credits

Total
:04
ContactHours: 52
Summative Assessment Marks 60
Formative Assessment Marks :40
:
60 Exam Duration:2:30 Hours
Exam Marks:
Unit - I

lotroduction to PHP: Introduction to PHP, History and Features of PHP, Installation & Configuration of PHP,
Embedding PHP code in Your Web Pages, Understanding PHP, HTML and White Space, Writing Comments
in PHP.Sending Data to the Web Browser, Data types in PHP, Keywords in PHP,Using Variables, Constants

in PHP, Expressions in PHP, Operators in PHP. [10 hours]

Unit - II

Programming with PHP: Conditional statements: if, if-else, switch, The ? Operator, Looping statements:
while Loop., do-while Loop,for Loop
Arrays in PHP: Introduction- What is Array?, Creating Arrays, Accessing Array elements, Typesof Arrays:
Indexed v/s Associative arrays, Multidimensional arrays, Creating Array. Accessing Array, Manipulating
Arrays, Displaying array, Using Array Functions, Including and Requiring Files- use of Include) and
Require), Implicit and Explicit Casting in PHP. [12hours]

Unit -II
Using Functions, Class-Objects, Forms in PHP: Functions inPHP, Function definition, Creating and
invoking user-defined functions, Formal parameters versusactual parameters, Function and variable scope,
Recursion, Library functions, Date and Time Functions
Strings in PHP: What is String?,Creating and Declaring String,String Functions [10hours]

Unit -IV
Class&Objects in PHP:What is Class & Object, Creating and accessing a Class &Object, Object properties,
methods, Overloading, inheritance, Constructor and Destructor
object

Form Handling: Creating HTML


Form, Handling Form data in HTML PHP Database Handling Using PHP
with MySQL: Introductionto MySQL: Database terms, Data Types. [10Hours]
Unit -V
AccessingMySQL -Using MySQL Client and Using php MyAdmin, MySQL Commands, Using PHP
with
MysQL: PHP MySQL Functions, Connecting to MySQL and
Selecting the Database, Executing Simple
Queries, Retrieving Query Results,Counting Returned Records, Updating
Records with PHP [09hours]

REFERENCES B0OKS
PHP& MySQL for Dynamic Web Sites-
Fourth Edition By Larry Ulman.
Learning PHP, MySQL and JavaScript By Robin Nixon-O
REILLY Publications
Programming PHP By Rasmus Lerdorf,
D.
Kevin Tatroe, Peter Macintyre
SAMS Teach Yourself PHP in 24 bours, Author: MattZandstra, Sams Publishing

You might also like