Showing posts with label WT. Show all posts
Showing posts with label WT. Show all posts

Sunday, December 10, 2017

PHP and AJAX

Test4.php:

<?php

$q=$_GET['q'];

$c=new mysqli("localhost","root","naina","nearur");

if($c->connect_error){
    die("eror : ".$c->connect_error);
}else{
    $sql="Select * from bank";

    $result=$c->query($sql);
    $h="";
    if($result->num_rows>0){
        while ($row=$result->fetch_assoc()) {
            $n=$row['userid'];
            if(stristr($q, substr($n, 0,strlen($q)))){
                if($h == ""){
                    $h=$n;
                }else{
                    $h.=" , ".$n;               
                }
            }

        }
        echo $h;
    }   
}

 ?>


Test4.html:

<html>
<head>
    <title></title>
<script type="text/javascript">
   
    function show(){
        alert("hello");
       
    }

</script>

<script>
function showHint(str) {
   
    if(str.length==0){
            document.getElementById("h").innerHTML="";
        }else{
        var xmlhttp = new XMLHttpRequest();
        xmlhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                document.getElementById("h").innerHTML = this.responseText;
            }
        };
        xmlhttp.open("GET", "test4.php?q=" + str, true);
        xmlhttp.send();

            /*var xml=new XMLHttpRequest();


            xml.onreadystatechange=function(){
                if(this.readyState==4 && this.status==200){
                    alert("hello");
                    document.getElementById.("h").innerHTML=this.responseText;
                }
            };

            xml.open("POST","test4.php",true);
            xml.setRequestHeader("Content-type","application/x-www-form-urlencoded");
            xml.send("q="+str);*/
        }
}
</script>


</head>
<body>
<form>
<input type="text" onkeyup="showHint(this.value)">
</form>
<p id="h">Suggestions</p>
</body>
</html>


Using Json in AJAX Application

Test.php file:


<?php 

$c=new mysqli("localhost","root","naina","nearur");

$obj = json_decode($_POST["v"], false);

$sql="Select * from ".$obj->table;


$result=$c->query($sql);

if($result->num_rows>0){
   
    $r = $result->fetch_all(MYSQLI_ASSOC);//{
    //    $s .="<tr><td>".$r["name"]."</td><td>".$r["userid"]."</td></tr>";
    //}
    //$s .="</table>";
    echo json_encode($r);
}else{
    echo "0 rows";
}


?>




Test.html:

<html>
<head>
    <title>WT</title>
<script type="text/javascript">
   
function g (a) {
    var my={"table":a};
    var json=JSON.stringify(my);
    var xml=new XMLHttpRequest();
    xml.onreadystatechange=function(){
        if(this.readyState==4&& this.status==200){
            var rjson=JSON.parse(this.responseText);
           
            txt="<table border='1'>";//<tr><th>ID</th><th>Name</th><th>Email</th><th>Roll</th><th>Gender</th><th>PINCODE</th><th>Mobile</th></tr>";
            for(x in rjson){
                txt+="<tr>";
                for (h in rjson[x]) {       
                txt+="<td>"+rjson[x][h]+"</td>";
                }
                txt+="</tr>";
            }
            document.getElementById("d").innerHTML=txt;
        }
    };

    xml.open("POST","test.php",true);
    xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xml.send("v="+json);
   
}


</script>

</head>

<body>
    <select onchange="g(this.value)" size="1">
        <option>.....Select....</option>
        <option>Users</option>
        <option>Bank</option>
        <option>Auri</option>
        <option>Student</option>
        <option>Employees</option>
    </select>
    <p id="d">Here</p>
</body>
</html>

Saturday, November 4, 2017

WT 11,12 JavaScript

Question: 
Create an HTML file to display the various arithmetic operations on variables using JavaScript.

Code:

<html>
<head>
<title>Arithmetic Operators</title>

<style type="text/css">
p{
color: white;
margin:1in;
margin-bottom: 0in;
margin-top: 0in;
text-align: center;
background-color: purple;
font-size: 25px;
font-family: Arial;
}
</style>

<script type="text/javascript">
function add(){
document.form1.result.value=parseInt(document.form1.a.value)+parseInt(document.form1.b.value);
}

function sub(){
document.form1.result.value=parseInt(document.form1.a.value)-parseInt(document.form1.b.value);
}

function mul(){
document.form1.result.value=parseInt(document.form1.a.value)*parseInt(document.form1.b.value);
}

function Div(){
document.form1.result.value=parseInt(document.form1.a.value)%parseInt(document.form1.b.value);
}
</script>
</head>
<body>
<center>
<p>This is a Simple Example  to display the various arithmetic operations on variables using JavaScript</p>
<br>
<br>
<form name="form1" style="font-size:20px;">
Enter First Number  : <input type="number" name="a" placeholder="Enter A : "/><br><br>
Enter Second Number : <input type="number" name="b" placeholder="Enter B : "/><br><br>
<button type="button" onClick="add()">+</button>&nbsp;&nbsp;<button type="button" onclick="sub()">-</button>&nbsp;&nbsp;<button type="button" onclick="mul()">*</button>&nbsp;&nbsp;<button type="button" onclick="Div()">%</button><br><br>
Result              : <input type="number" name="result" placeholder="Result :">
</form>
</center>
</body>
</html> 

Output:



Question:

Create an HTML file to implement the concept of document object model using JavaScript.

Code:
 <html>
<head>
<script type="text/javascript">
function change(){

var a=document.getElementById("Jarvis");
a.innerHTML="This Is Text After Clicking On Below Button";

a.style.color = "blue";
a.style.fontFamily = "Arial";
a.style.fontSize = "larger";
}

</script>


<style type="text/css">
h1{
color: white;
margin:1in;
margin-bottom: 0in;
margin-top: 0in;
text-align: center;
background-color: purple;
font-size: 25px;
font-family: Arial;
}
</style>

</head>

<body>
<h1>This is a simple Example  to implement the concept of document object model using
JavaScript. </h1>

<p id='Jarvis'>Clicking Below Button Will Change The Element Having Id='Jarvis'</p>
<center><button onclick="change()">Click Here</button></center>

</body>

</html>

Output:


WT 13,14,15 PHP Practicals

Question:
. Create a PHP file to print any text using variable

Code:
<html>

<head>
<?php
$variable="Hello World";
echo "<center><h1>".$variable."</h1></center>";
?>

<style type="text/css">
h1{
color: white;
background-color: purple;
font-size: 50px;
font-family: Arial;
}
</style>
</head>

<body>
<p style="font-size:30px;">This is a Simple Example To Show Text Using Variable in PHP</p>

</body>

</html>

Output:


Question:
 Demonstrate the use of statements, operators and functions in PHP.

Code:
<html>

<head>
<?php

if(isset($_POST['c'])){
$a=$_POST['a'];
$b=$_POST['b'];
$d=$_POST['d'];

operate($a,$b,$d);
}

function operate($a,$b,$d)
{
if(!(empty($a)||empty($b))){
if($d=="Add"){
echo "<html><h1>Result is : ".($a+$b)."</h1></html>";
}
else if($d=="Subtract"){
echo "<html><h1>Result is : ".($a-$b)."</h1></html>";
}
else if($d=="Multiply"){
echo "<html><h1>Result is : ".($a*$b)."</h1></html>";
}
else if($d=="Modulus"){
echo "<html><h1>Result is : ".($a%$b)."</h1></html>";
}
}else{
echo "All Fields are Mandatory";
}
}

?>

<style type="text/css">
h1{
color: white;
background-color: purple;
font-size: 50px;
font-family: Arial;
}
</style>
</head>

<body>
<p style="font-size:30px; text-align:center;">This is a Simple Example To Demonstrate the use of statements, operators and functions in PHP</p>

<center>
<form action="wt13.php" method="post">
<input type="number" name="a" placeholder="Enter A : ">
<input type="number" name="b" placeholder="Enter B : ">
<select name="d">
<option>Add</option>
<option>Subtract</option>
<option>Multiply</option>
<option>Modulus</option>
</select>
<input type="submit" value="Submit" name="c">
</form>
</center>

</body>

</html>

Output:

Question:
Demonstrate the use of Loops and arrays in PHP

Code:

<html>

<head>
<?php
if(isset($_POST['c']))
{

$array=array();
$a=$_POST['a'];

for($i=1;$i<=10;$i++){
$array[$i]=$a*$i;
// echo $a." * ".$i." = ".($a*$i);
}


for($i=1;$i<=10;$i++){
echo "<h1>",$a." * ".$i." = ".$array[$i]."</h1><br>";
}
}



?>

<style type="text/css">
h1{
color: white;
margin:1in;
margin-bottom: 0in;
margin-top: 0in;
text-align: center;
background-color: purple;
font-size: 30px;
font-family: Arial;
}
</style>
</head>

<body>
<p style="font-size:30px; text-align:center;">This is a Simple Example To Demonstrate the use of Loops and arrays in PHP</p>

<center>
<form action="wt13.php" method="post">
<input type="number" name="a" placeholder="Enter Any Number : " required>
<input type="submit" value="Submit" name="c">
</form>
</center>

</body>

</html>

Output:

Wednesday, November 1, 2017

Wt Practical 8,9,10

Code:

<html>
<head>
<link rel="stylesheet" type="text/css" href="Wt8.css">
<style type="text/css">
h2{
font-size:40px;
font-family: Arial;
text-align: center;
}
</style>
</head>

<body>
<h1 style="font-size:50px; text-align:left; font-family:TimesNewRoman; ">Inline Style</h1>
<h2>Internal Style</h2>
<h3>External Style</h3>
</body>
</html>


Wt8.css:

h3{
font-size: 40px;
font-family: Courier;
text-align: right;
}


Output:
Code:
<html>
<head>
<style type="text/css">
a{
font-family:Helvetica;
font-size: 30px;
}
a:visited{
color: red;
}

a:link{
color: yellow;
}

a:hover{
color: green;
font-size: 40px;
}
p{
text-align: center;
font-size: 50px;
font-family: Arial;
color: blue;
}
</style>
</head>
<body>

<p>Click On Below Links And You Will Be Redirected</p>
<ul type="square">
<li><a href="https://www.google.co.in/?q=hello U">iPhoneX</a></li>
<li><a href="https://www.google.co.in/">iPhone8</a></li>
<li><a href="https://www.google.co.in/?q=bye U">iPhone7</a></li>
</ul>


</body>
</html>

Output:

Code:

<html>
<head>
<style type="text/css">
table th{
background-color: purple;
color: white;
}

table tr{
font-family: Arial;
font-size: 20px;
}
table tr:hover{
background-color: green;
}

ul{
list-style: squares;
}
ul li{
font-size: 20px;
font-family: Arial;
}
ul li:hover{
color: red;
}
</style>
</head>
<body>

<center><h3>Key Specs iPhone7</h3>
<table border="2" cellpadding="5" cellspacing="5">
<tr><td>Display</td><td>Processor</td><td>Front Camera</td></tr>
<tr><th>4.70-inch</th><th>quad core</th><th>7-megapixel</th></tr>
<tr></tr>
<tr><td>Resolution</td><td>OS</td><td>Storage</td></tr>
<tr><th>750x1334 pixels</th><th>iOS 10</th><th>32GB</th></tr>
<tr></tr>
<tr><td>Rear Camera</td><td>Price</td></tr>
<tr><th>12-megapixel</th><th>Rs. 45,999</th></tr>
</table>
</center>
<br>
<ul>
<li>iPhone7</li>
<li>iPhone7+</li>
<li>iPhone8</li>
<li>iPhone8 plus</li>
<li>iPhoneX</li>
</ul>



</body>
</html>

Output:

Sunday, October 8, 2017

WT practicals 5,6,7

Login.html


<html>
<title>Login</title>
<head><center><font size="20" color="aqua" face="Times New Roman">Login</font></center>
<script language="javascript">
function my(){
if(f.m1.value="9023074222" && f.p1.value="1507623"){
alert('Welcome Iron Man');
return true;
document.getElementById('demo').innerHtml="Hello";

}else{
alert('Wrong Credentials');
return false;
}
}


</script>
</head>
<body background="t.jpg">
<center>
<p id="demo"></p>
<font size="5" color="red"><p>* Mandatory Fields</p></font>
<form name="f" action="" method="post">
<pre>
<font size="5" color="DarkTurquoise" face="Arial">
Mobile Number:<font color="red">*</font>    <input type="number" name="m1" required placeholder="Mobile Number" style="margin-left:-0.2in;"><br>
Password:<font color="red">*</font>    <input type="password" name="p1" required placeholder="Password" style="margin-left:0.3in;"><br><br>
<input type="submit" name="s"  value="Submit" onClick="my()">     <input type="reset" value="Reset" name="r1"><br>
<a href="forgot.html" >Forgot Password</a>
</font>
</pre>
</form>
</center>
<marquee direction="left" behavior="alternate"><img src="f.png" height=200 width=200>   <img src="i.png" height=200 width=200>    <img src="tw.png" height=200 width=200>
</marquee>

</body>
</html>

Output:



Registration.html


<html>
<head><title>Register Nearur</title>
<center style="color:purple; font-size:50px;">Registration Form</center>
<img src="photo.jpg" width="200px" height="200px">
</head>
<style>
.b
{
font-size:25px;
}
</style>
<body>
<br>
<br>
<center>
<form method="post" action="reg.php">
<table style=" font-size:25px; margin-top:-2in;">
<tr><td>First Name:</td> <td><input type="text" required name="a1" class="b"></td></tr>
<tr><td>Last Name:</td> <td>  <input type="text" required name="a2"class="b"></td></tr>
<tr><td>Mobile Number:</td> <td> <input type="number" required name="a3"class="b"></td></tr>
<tr><td>Password:</td> <td> <input type="password" required name="a4"class="b"></td></tr>
<tr><td>Retype Password:</td> <td> <input type="password" required name="a5"class="b"></td></tr>
<tr><td>Address:</td> <td> <input type="text" required name="a6"class="b"></td></tr>
<tr><td>Security Question:</td> <td> <select required name="a7"class="b"><option>What is Your Nickname?</option><option>Who is your favourite Cricket Player?</option><option>What is your BirthPlace?</option><option>Which is your Favourite Dish?</option></select></td></tr>
<tr><td>Answer:</td> <td> <input type="text" required name="a8"class="b"></td></tr>
</table>
<br>
<input type="submit" name="a9" value="Register" class="b">&nbsp;<input type="reset" name="b" value="Reset" class="b">
</form>
</center>
<marquee behavior="alternate" scrollamount="9"><img src="b.jpg" width="300px" height="200px"><img src="c.jpg" width="300px" height="200px"><img src="d.jpg" width="300px" height="200px"></marquee>
</body>
</html>

Output:



Link.html


<html>
<head>
<title>Practical5</title>
</head>
<body background=""><center>
<h1 style="font-size:50px; font-family:Arial;">Nearur</h1>
<p style="font-size:25px; font-family:Arial;">Choose From Below Mobiles</p>
<a href="#8" title="#8"><img src="8.jpeg" align="left" /></a>
<a href="X.html" title="X.html"><img src="9.png" align="right" style="margin-right:1.5in;"></a>
</center>
</body>

</html>

Output: