75% found this document useful (4 votes)
1K views

DWPD Manual HTML

The document contains 14 code snippets demonstrating various HTML and PHP coding concepts. The snippets include: 1. Displaying an image using the <img> tag 2. Using the <a> anchor tag to create a hyperlink 3. Creating and styling a table with the <table> tag 4. Generating ordered and unordered lists with the <ul> and <ol> tags 5. Embedding a video using the <video> tag 6. Dividing a page into sections using <div> tags and CSS styling 7. Creating a student information form using various form input tags 8. A basic "Hello World" PHP script 9. A PHP script to calculate the

Uploaded by

Rohan Shah
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
75% found this document useful (4 votes)
1K views

DWPD Manual HTML

The document contains 14 code snippets demonstrating various HTML and PHP coding concepts. The snippets include: 1. Displaying an image using the <img> tag 2. Using the <a> anchor tag to create a hyperlink 3. Creating and styling a table with the <table> tag 4. Generating ordered and unordered lists with the <ul> and <ol> tags 5. Embedding a video using the <video> tag 6. Dividing a page into sections using <div> tags and CSS styling 7. Creating a student information form using various form input tags 8. A basic "Hello World" PHP script 9. A PHP script to calculate the

Uploaded by

Rohan Shah
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/ 33

1 Write a HTML code to display image on webpage.

<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>

For Image <a href="ImageInHTML.html">click here</a>

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

<video height="400" weight"300" autoplay controls>


<source src="video.mp4" type="video/mp4" />
Your browser does not support the <video> element.
</video>

</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="">

Student Name:- <input type="text" name="name">


<br>
<br>
En_No. :- <input type="number" name="enno">
<br>
<br>
Age:- <input type="number" name="age">
<br>
<br>
Sex :-
Male<input type="radio" name="sex">
Fmale<input type="radio" name="sex">
<br>
<br>
Interest's :-
Acting<input type="checkbox" name="interests">
Dance<input type="checkbox" name="interests">
Music<input type="checkbox" name="interests">
Reading<input type="checkbox" name="interests">
Sports<input type="checkbox" name="interests">
<br>
<br>
City :-
<select name="city">
<option>Ahemdabad</option>
<option>Balasinor</option>
<option>Gandhinagar</option>
<option>Porbandar</option>
<option>Thermal</option>
</select>
<br>
<br>
Pincode:- <input type="number" name="pin">
<br>
<br>
<input type="submit" name="submit">

</form>
</h4>
</body>
</html>
8 Write a PHP program to display Hello World.

<html>

<body>

<?php

echo "Hello World!";

?>

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

<center><h1>Program in php with HTML to find odd or


even.</h1></center>
<br>
<center>
<form name="oddeven" action="odd-even 2.php"
method="POST">
<h3>Enter Number In Digit.</h3>
<br>
<input type="text" name="num">
<br>
<h3>Press " SUBMIT " To Find Odd Or Even.</h3>
<br>
<input type="submit" name="submit" value="SUBMIT">
</form>
</center>

<?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><h1>Program in php with HTML to find Max or


Min.</h1></center>
<br>

<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";

echo "Salary of Ruchir is ".$salaries['Ruchir'].'<br>';


echo "Salary of Rachita is ".$salaries['Rachita'].'<br>';
echo "Salary of Komal is ".$salaries['Komal'].'<br>';
?>

</center>
</body>
</html>
15 Write a PHP program to demonstrate (1) date/time (2) string (3) array functions

Date /Time Function


<?php
date_default_timezone_set('Asia/Calcutta');
?>
<html>
<body>
<center>
<?php
echo
"**************************TIMEFUNCTION***********************
**";
echo "<br>".time();
?>
<table border=1>
<tr>
<h2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DATE
FUNCTION:&nbsp;</h2>
</tr>
<tr>
<td>date('d-m-y')</td>
<td><?php echo date('d-m-y');?></td>
</tr>
<tr>
<td>date('D-M-Y')</td>
<td><?php echo date('D-M-Y');?></td>
</tr>
<tr>
<td>date('l-F-Y')</td>
<td><?php echo date('l-F-Y');?></td>
</tr>
<tr>
<td>date('D-M-Y h:i:s')</td>
<td><?php echo date('l-F-Y h:i:s');?></td>
</tr>
<tr>
<td>date('j-n-y')</td>
<td><?php echo date('j-n-y');?></td>
</tr>
<tr>
<td>day numder = date('N D-M-Y')</td>
<td><?php echo date('N D-M-Y');?></td>
</tr>
<tr>
<td>number of days in this month = date('t D-M-
Y')</td>
<td><?php echo date('t D-M-Y');?></td>
</tr>
</table>
</body>
</html>
String Function
<html>
<body>
<?php
echo "<center>";
echo "Main String"."<h2>"." Balasinor College of Polytechnic
"."</h2>";
echo "</center>";
echo "<br>";
//strtolower()
$str = "Balasinor College of Polytechnic";
echo $str;
echo "<br>";
$str = strtolower($str);
echo $str;
//strtoupper()
$str = strtoupper($str);
echo "<br>";
echo $str;
//strlen()
$str = strlen($str);
echo "<br>";
echo $str;
//substr()
$str = substr($str,-3);
?>
</body>
</html>
Array Function

<?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">

<h3>En_No.</h3><input type="text" name="no">


<br>
<h3>Name</h3><input type="text" name="name">
<br>
<h3>Branch</h3><input type="text" name="branch">
<br>
<h3>Semester</h3><input type="text" name="sem">
<input type="submit" name="submit" value="SUBMIT">

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

mysql_connect("localhost","root","")or die (mysql_error());


mysql_select_db("simplecounter")or die (mysql_error());

$find_counts = mysql_query("SELECT * FROM user_count");

while ($row = mysql_fetch_assoc($find_counts))


{
$current_counts = $row['counts'];
}
$new_count = $current_counts + 1;
$q1 = "UPDATE user_count SET counts = $new_count";
mysql_query($q1)or die(mysql_error());
echo " you are ".$new_count." number of visitor ";

?>
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>

You might also like