DWPD Manual HTML
DWPD Manual HTML
<html>
<head>
<title>Image</title>
</head>
<body>
<img src="Desert.jpg">
</body>
</html>
2 Write a HTML code to demonstrate anchor tag.
<html>
<head>
<title>Anchor</title>
</head>
<body>
<h2>
</h2>
</body>
</html>
3 Write a HTML code to display table on webpage.
<html>
<head>
<title>Table Tag</title>
</head>
<body>
<h1>Table</h1>
<hr>
<center><table border="5"></center>
<tr>
<td>Apple</td>
<td rowspan="2">Banana</td>
<td>Cherry</td>
</tr>
<tr>
<td>Football</td>
<td>Cricket</td>
</tr>
</table>
</body>
</html>
4 Write a HTML code to design list.
<html>
<head>
<title>List Tag</title>
</head>
<body>
<h2>List Tag</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
<li>Pinaple</li>
<li>Watermelon</li>
</ul>
<br>
<ol>
<li>Tiger</li>
<li>Turtle</li>
<li>Rabbit</li>
<li>Deer</li>
<li>Elephant</li>
</ol>
</body>
</html>
5 Write a HTML code to attach video on webpage.
<html>
<head>
<title>Video</title>
</head>
<body>
</body>
</html>
6 Write a HTML code to static webpage by div tag.
<html>
<head>
<title>Div Tag</title>
<style type="text/css">
.d1 {
float: right;
color: coral;
background: aqua;
}
.d2 {
float: center;
text-align: center;
color: darkgoldenrod;
}
.d3 {
float: left;
color: cadetblue;
background: brown;
}
</style>
</head>
<body>
<div class="d1">
<h3>World in HTML</h3>
</div>
<div class="d2">
<h3>Hello! in HTML</h3>
</div>
<div class="d3">
<h3>PHP in HTML</h3>
</div>
</body>
</html>
7 Create student detail for in HTML using form handling.
<html>
<head>
<title></title>
</head>
<body>
<h1>Student Form</h1>
<hr>
<h4>
<form name="student_1" action="" method="">
</form>
</h4>
</body>
</html>
8 Write a PHP program to display Hello World.
<html>
<body>
<?php
?>
</body>
</html>
9 Write a PHP program to find sum of first 10 numbers.
<html>
<head><title>Addition</title></head>
<body>
<h1>Program of Addition of 1 to 10 Numbers</h1>
<?php
$a;
$sum=0;
for($a=1;$a<=10;$a++)
{
$sum=$sum+$a;
}
echo $sum;
echo "<br>";
echo "$sum";
echo "<br>";
echo '$sum';
?>
</body></html>
10 Write a PHP program to find whether given number is odd or even.
<html>
<head>
<title>Odd or Even</title>
</head>
<body>
<?php
if (isset($_POST['submit']))
{
if($a=$_POST['num']);
}
if($a%2==0)
{
echo '$a '."whose value is $a ".'is EVEN';
}
else
{
echo '$a '."whose value is $a ".'is ODD';
}
?>
</body></html>
Write a PHP program to display following pattern.
11 1 1 *
22 12 **
333 123 ***
1st Pattern
<html>
<head>
<title>Pattern</title>
</head>
<body>
<?php
$i;
$j;
for($i=0;$i<=3;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo " $i ";
}
echo '<br>' ;
}
?>
</body>
</html>
2nd Pattern
<html>
<head>
<title>Pattern</title>
</head>
<body>
<?php
$i;
$j;
for($i=0;$i<=5;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo " * ";
}
echo '<br>' ;
}
?>
</body>
</html>
3rd Pattern
<html>
<head>
<title>Pattern</title>
</head>
<body>
<?php
$i;
$j;
for($i=0;$i<=5;$i++)
{
for($j=1;$j<=$i;$j++)
{
echo " * ";
}
echo '<br>' ;
}
?>
</body>
</html>
12 Write a PHP program to print Fibonacci series.
<html>
<head>
<title>Fibonacci</title>
</head>
<body>
<?php
$num = 0;
$n1 = 0;
$n2 = 1;
echo "<h2>Fibonacci series for first 12 numbers:
</h2>";
echo "\n";
echo $n1.' '.$n2.' ';
while ($num < 10 )
{
$n3 = $n2 + $n1;
echo $n3.' ';
$n1 = $n2;
$n2 = $n3;
$num = $num + 1;
}
?>
</body>
</html>
13 Write a PHP program to find maximum number out of 3 given numbers.
<html>
<head>
<title>Max - Min</title>
</head>
<body>
<center>
<form name="max-min" action="max-min.php" method="GET">
<h3>Enter Number In Digit.</h3>
<br>
<input type="number" name="num1">
<br>
<input type="number" name="num2">
<br>
<input type="number" name="num3">
<br>
<h3>Press " SUBMIT " To Find Maximum Or
Minimum.</h3>
<br>
<input type="submit" name="submit"
value="SUBMIT">
</form>
</center>
<?php
if (isset($_GET['submit']))
{
$a=$_GET['num1'];
$b=$_GET['num2'];
$c=$_GET['num3'];
if($a>$b && $a>$c)
{
echo '$a '."whose value is $a ".'is MAX';
}
elseif($b>$a && $b>$c)
{
echo '$b '."whose value is $b ".'is MAX';
}
elseif($c>$a && $c>$b)
{
echo '$c '."whose value is $c ".'is MAX';
}
else
{
echo "<h3>All Equals<h3>";
}
}
?>
</body>
</html>
14 Write a PHP program to display associative array using foreach loop.
<html>
<head>
<title>Array 5</title>
</head>
<body>
<center>
<h1>This is Array 5</h1>
<h3>Associative Array</h3>
<br>
<hr>
<br>
<?php
$salaries = array(
"Ruchir" => 2000,
"Rachita" => 1000,
"Komal" => 500
);
echo "Salary of Ruchir is ".$salaries['Ruchir'].'<br>';
echo "Salary of Rachita is ".$salaries['Ruchir'].'<br>';
echo "Salary of Komal is ".$salaries['Komal'].'<br>';
echo '<br>';
$salaries['Ruchir']="high";
$salaries['Rachita']="medium";
$salaries['Komal']="low";
</center>
</body>
</html>
15 Write a PHP program to demonstrate (1) date/time (2) string (3) array functions
<?php
$array1 = array(10,20,30,40);
$array2= array(50,60,70,80,90);
echo "<center>";
echo "<h2> Array1 is (10,20,30,40)</h2>";
echo "<h2> Array2 is (90,80,70,60)</h2>";
echo "</center>";
//count array
echo count($array1);
echo "<br>";
echo count($array2);
//array merge
$array3 = array_merge($array1,$array2);
echo "<br>";
print_r($array3);
//array sort
echo "<br>";
if(sort($array2)){
print_r($array2);
}
?>
16 Write a PHP program to create student registration form using form elements.
<html>
<head>
<title>Student Registration</title>
</head>
<body><center>
<h1> Student Registration Form </h1>
<h2> Form </h2>
</center>
<form name="form1" action="Stu Disp.php" method="POST">
</form>
</body>
</html>
<html>
<head>
<title>Display</title>
</head>
<body>
<center>
OK
<?php
if (isset($_POST['submit']))
{
$no=$_POST['no'];
$name=$_POST['name'];
$branch=$_POST['branch'];
$sem=$_POST['sem'];
$a=mysql_connect("localhost","root","") or die
(mysql_error());
$b=mysql_select_db('student') or die (mysql_error());
$c="insert into stu_detail
values('$no','$name','$branch','$sem')";
$q=mysql_query($c) or die(mysql_error());
//$q=mysql_query("insert into stu_detail
values('$no','$name','$branch','$sem')") or die
(mysql_error());
}
?>
</center>
</body></html>
17 Write a PHP program to create user login form using form in PHP.
<html>
<head>
<title>Login</title>
</head>
<body>
<center>
<h1>Login Form</h1>
<hr>
<form name="form1" action="Index 1.php" method="POST">
<h2>Username</h2><input type="text" name="name">
<br>
<br>
<h2>Password</h2><input type="password" name="pwd">
<br>
<br>
<input type="submit" name="submit" value="Login">
</form>
</center>
</body>
</html>
<html>
<head>
<title>Index</title>
</head>
<body>
<center>
<?php
if (isset($_POST['submit']))
{
$name=$_POST['name'];
$pwd=$_POST['pwd'];
if ($name=="ruchir" && $pwd=="1234")
{
echo "Welcome";
echo "<br>";
echo $name;
echo "<br>";
}
Else
{
echo "Username or Pssword is INVALID";
echo "<br>";
echo '<a href="Login 1.html">'."CLICK HERE".'</a>';
}
}
?>
</center>
</body>
</html>
18 Write a PHP program to pass variable with session.
<?php
//session starts from here
//session function
session_start();
?>
<html>
<body>
<?php
//session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favpet"] = "dog";
echo "Session variables are set.";
?>
</body>
</html>
19 Write a PHP program to pass variable with cookie.
<?php
$cookie_name = "user";
$cookie_value = "php BCP";
setcookie($cookie_name, $cookie_value, time() + (86400 * 30),
"/"); // 86400 = 1 day
?>
<html>
<body>
<?php
if(!isset($_COOKIE[$cookie_name])) {
echo "Cookie named '" . $cookie_name . "' is not set!";
} else {
echo "Cookie '" . $cookie_name . "' is set!<br>";
echo "Value is: " . $_COOKIE[$cookie_name];
}
?>
</body>
</html>
20 Write a PHP program to demonstrate hit counter.
<?php
?>
21 Write a PHP program to insert a data and display all the data in table form on
output screen.
<html>
<head>
<title>Table FORM</title>
</head>
<body>
<table border="5">
<?php
mysql_connect("localhost","root","")or
die(mysql_error());
mysql_select_db("student")or die(mysql_error());
$q = mysql_query("SELECT * FROM stu_detail");
while($row = mysql_fetch_array($q))
{
echo "<tr>";
echo "<td>".$row['no']."<td>";
echo "<td>".$row['name']."<td>";
echo "<td>".$row['branch']."<td>";
echo "<td>".$row['sem']."<td>";
}
?>
</table>
</body>
</html>