PHP Css 22

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

PART A

1. Develop and demonstrate HTML pages containing basic text formatting tags,
hyperlink, images.

1A.html

<html>
<head>
<title> Fruit Program </title>
</head>
<body>
<h1 align="center"> Fruit Information</h1>
<hr color=red>
<center>
<h1>Apple</h1>
<img src="Img_A1_1.jfif" /><br>
<a href="Pro_A1_1.html" >Click Here</a>
<h1>Orange</h1>
<img src="Img_A1_2.jfif" /><br>
<a href="Pro_A1_2.html" >Click Here</a>
</center>
</body>
</html>

1A_1.html

<html>
<head>
<title> Apple Information</title>
</head>
<body bgcolor="lightblue" >
<center>
<h1 > Apple</h1>
</center>
<hr color=red>
<p align="justify">
An <b> apple</b> is an edible fruit produced by an<strong> apple tree</strong>
<i>
(Malus domestica)</i>. Apple trees are cultivated worldwide and are the most
widely
<em>grown species in the genus Malus</em>. The tree originated in Central Asia,
where its
wild ancestor, Malus sieversii, is still found today. Apples have been grown for
thousands of
years in Asia and Europe and were brought to North America by European
colonists. Apples
have religious and mythological significance in many cultures, including
<small>Norse, Greek,
and European Christian tradition</small>.
Apple trees are large if <ins>grown from seed</ins>. Generally, apple cultivars
are
propagated by grafting onto rootstocks, which control the size of the resulting tree.
There are
more than 10<sup>3</sup> known cultivars of apples, resulting in a range of
desired
characteristics. Different cultivars are bred for various tastes and use, including
cooking, eating
raw and cider production. Trees and fruit are prone to a number of fungal, bacterial
and pest
problems, <mark>which can be controlled by a number of organic and non-organic
means</mark>. In 2010, the fruit's genome was sequenced as<del> part of research
on disease
control</del> and selective breeding in apple production. it has H<sub>2</sub>o
content in it.
</p>
</body>
</html>

3. Write a JavaScript Program to find the factorial of a Given Number (Accept


input using Prompt Box).
<html>
<head>
<title> Factorial</title>
<style>
.button
{
background-color: red;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
font-size: 16px;
}
</style>
</head>
<body>
<center>
<h1 > Factorial</h1>
</center>
<hr color=red>
<center>
<button class="button" onclick = "fact()"> Factorial </button>
</center>
<script>
function fact()
{
var i, num, f;
f = 1;
num = prompt("Enter the Number");
for(i = 1; i <= num; i++)
{
f = f * i;
}
alert("Factorial of the Given Number is-->"+f);
}
</script>
</body>
</html>

4. Write a JavaScript Program to Implement login page (if login credentials are
correct, display ‘login
successful’ or display ‘login unsuccessful’ using alert)
<html>
<head>
<title> Login Credentials </title>
<style>
body {
background-color: lightblue;
}
</style>
<script>
function check()
{
var user=document.getElementById("User_Name").value;
var pass=document.getElementById("User_Pass").value;
if(user=="JSS" && pass=="123")
{
alert("login in Successfull");
}
else
{
alert("Login is UnSuccessfull");
}

}
</script>
</head>
<body>
<center>
<h1> Login Credentials</h1>
</center>
<hr>
<center>
<form>
<table border=1>
<tr>
<td colspan="2" style="text-align:center">
LOGIN
</td>
</tr>
<tr>
<td> User Name:</td>
<td> <input type="text" id="User_Name"></td>
</tr>
<tr>
<td>Password:</td>
<td> <input type="password" id="User_Pass"></td>
</tr>
<tr>
<td></td>
<td> <input type="submit" id="submit" value="submit" onclick="check()">
<input type="reset" id="submit" value="reset">
</td>
</tr>
</table>
</form>
</body>
</html>

PART B

1. <!-- Write a PHP program to Generate Multiplication table using


Loop-->

<?php

echo "<table border =\"1\" style='border-collapse: collapse'>";

for ($row=1; $row <= 10; $row++) {

echo "<tr> \n";

for ($col=1; $col <= 10; $col++) {

$p = $col * $row;

echo "<td>$p</td> \n";


}

echo "</tr>";

echo "</table>";

?>

Write a PHP function to test whether a number is greather than 30, 20 or 10


sing Ternary Operator -->

<?php

function trinary_Test($n){

$r = $n > 30 ? "greater than 30"

: ($n > 20 ? "greater than 20"

: ($n > 10 ? "greater than 10"

: "Input a number atleast greater than 10!"));

echo $n." : ".$r."\n";

echo "<br>";

trinary_Test(32);

trinary_Test(21);

trinary_Test(12);
trinary_Test(4);

?>

1. <!-- Create a simple HTML, forma nd accept the user name and display
the name through php echo statement -->

<!DOCTYPE html>

<html>

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

</head>

<body>

<form method='POST'>

<h2>Please input your name:</h2>

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

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

</form>

<?php

//Retrieve name from query string and store to a local variable

if (isset($_POST ["name"]))

if ($_POST ["name"] != "") {

$name = $_POST["name"];

echo "<h3> Hello $name </h3>";


}

?>

</body>

</html>

PART B
1. <!-- Write a PHP script, which changes the color of the first character of
a word-->

<?php

$text = 'Welcome to PHP';

$text = preg_replace('/(\b[a-z])/i','<span style="color:red;">\1</span>',$text);

echo $text;

?>

You might also like