Posts

Showing posts from December, 2019

PROG 10

10. Write a PHP program to sort the student records which are stored in the database using selection sort. Goto Mysql and then type create database weblab;  use weblab; create table student(usnvarchar(10),name varchar(20),address varchar(20)); program10.php <!DOCTYPE html> <html> <body> <style>    table, td, th    {     border: 1px solid black;     width: 33%;     text-align: center;    border-collapse:collapse;    background-color:lightblue;    }    table { margin: auto; }  </style> <?php $servername = "localhost"; $username = "root"; $password = "root"; $dbname = "weblab"; $a=[];   // Create connection // Opens a new connection to the MySQL server  $conn = mysqli_connect($servername, $username, $password, $dbname);     if ($conn->connect_error)  ...

PROG 9

9. Write a PHP program named states.py that declares a variable states with value "Mississippi Alabama Texas Massachusetts Kansas". program9.php  <?php  $states = "Mississippi Alabama Texas Massachusetts Kansas"; $statesArray = [];  $states1 = explode(' ',$states);  echo "Original Array :<br>";  foreach ( $states1 as $i => $value )   print("STATES[$i]=$value<br>");  foreach($states1 as $state)  {   if(preg_match( '/xas$/', ($state)))   $statesArray[0] = ($state);  }  foreach($states1 as $state) {   if(preg_match('/^k.*s$/i', ($state)))   $statesArray[1] = ($state);  }   foreach($states1 as $state) {   if(preg_match('/^M.*s$/', ($state)))   $statesArray[2] = ($state);  }  foreach($states1 as $state) {   if(preg_match('/a$/', ($state)))   $statesArray[3] = ($state);  }  echo "...

PROG 8

8 (a) . Write the PHP programs to do the following: a) Implement simple calculator operations. b) Find the transpose of a matrix. c) Multiplication of two matrices. d) Addition of two matrices. program8a.php <html> <head> <style>   table, td, th   {    border: 1px solid black;    width: 35%;    text-align: center;    background-color: DarkGray;   }   table { margin: auto; }    input,p { text-align:right; }  </style> </head> <body> <form method="post">  <table>   <caption><h2> SIMPLE CALCULATOR </h2></caption>> <tr><td>First Number:</td><td><input type="text" name="num1" /></td> <td rowspan="2"><input type="submit" name="submit" value="calculate"></td></tr> <tr><td>Second Number:</td><td><input ...

PROG 7

7. Write a PHP program to display a digital clock which displays the current time of the server. program7.php <!DOCTYPE HTML> <html> <head> <meta http-equiv="refresh" content="1"/> <style>  p {    color:white;    font-size:90px;    position: absolute;    top: 50%;    left: 50%;    transform: translate(-50%, -50%);   }   body{background-color:black;}  </style>  <p> <?php echo date(" h: i : s  A");?> </p> </head> <html>

PROG 6

6. Write a PHP program to keep track of the number of visitors visiting the web page and to display this count of visitors, with proper headings. program6.php <?php print "<h3> REFRESH PAGE </h3>"; $name="counter.txt"; $file = fopen($name,"r"); $hits= fscanf($file,"%d"); fclose($file); $hits[0]++; $file = fopen($name,"w"); fprintf($file,"%d",$hits[0]); fclose($file); print "Total number of views: ".$hits[0]; ?>

Prog 5

5. Design an XML document to store information about a student in an engineering college affiliated to VTU. The information must include USN, Name, and Name of the College, Branch, Year of Joining, and email id. Make up sample data for 3 students. Create a CSS style sheet and use it to display the document. program5.xml <?xml-stylesheet type="text/css" href="5.css" ?> <!DOCTYPE HTML> <html> <head> <h1>  STUDENTS DESCRIPTION </h1> </head> <students> <student>   <USN>USN         :   1RN07CS001</USN>   <name>NAME       :   SANTHOSH</name>   <college>COLLEGE :   RNSIT</college>   <branch>BRANCH   :   Computer Science and Engineering</branch>   <year>YEAR       :   2007...

Prog 4

4. Develop and demonstrate a HTML5 file that includes JavaScript script that uses functions for the following problems: a) Parameter: A string b) Output: The position in the string of the left-most vowel c) Parameter: A number d) Output: The number with its digits in the reverse order program4.html <!DOCTYPE HTML> <html> <body> <script type="text/javascript"> var str = prompt("Enter the Input",""); if(!(isNaN(str))) { var num,rev=0,remainder; num = parseInt(str); while(num!=0) { remainder = num%10; num = parseInt(num/10); rev = rev * 10 + remainder; } alert("Reverse of "+str+" is "+rev); } else { str = str.toUpperCase(); for(var i = 0; i < str.length; i++) { var chr = str.charAt(i); if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U')break; } if( i < str.length ) alert("The position of the left most vowel is ...

PROG 3

3. Write a JavaScript code that displays text “TEXT-GROWING” with increasing font size in the interval of 100ms in RED COLOR, when the font size reaches 50pt it displays “TEXT-SHRINKING” in BLUE color. Then the font size decreases to 5pt. program3.html <!DOCTYPE HTML> <html> <head> <style> p { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } </style> </head> <body> <p id="demo"></p> <script> var var1 = setInterval(inTimer, 1000); var fs = 5; var ids = document.getElementById("demo"); function inTimer() { ids.innerHTML = 'TEXT GROWING'; ids.setAttribute('style', "font-size: " + fs + "px; color: red"); fs += 5; if(fs >= 50 ){ clearInterval(var1); var2 = setInterval(deTimer, 1000); } } function deTimer() { fs -= 5; ids.innerHTML = 'TEXT SHRINKING'; ids.setAttribute('style', "font-size: ...

PROG 2

2. Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10 and outputs HTML text that displays the resulting values in an HTML table format. program2.html <!DOCTYPE HTML> <html> <head> <style> table,tr, td { border: solid black; width: 33%; text-align: center; border-collapse: collapse; background-color:lightblue; } table { margin: auto; } </style> <script> document.write( "<table><tr><th colspan='3'> NUMBERS FROM 0 TO 10 WITH THEIR SQUARES AND CUBES </th></tr>" ); document.write( "<tr><td>Number</td><td>Square</td><td>Cube</td></tr>" ); for(var n=0; n<=10; n++) { document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>" ) ; } document.write( "</table>" ) ...

PROG 1

1. Write a JavaScript to design a simple calculator to perform the following operations: sum, product, difference and quotient. program1.html <!DOCTYPE HTML> <html> <head> <style> table, td, th { border: 1px solid black; width: 33%; text-align: center; background-color: DarkGray; border-collapse:collapse; } table { margin: auto; } input { text-align:right; } </style> <script type="text/javascript"> function calc(clicked_id) { var val1 = parseFloat(document.getElementById("value1").value); var val2 = parseFloat(document.getElementById("value2").value); if(isNaN(val1)||isNaN(val2)) alert("ENTER VALID NUMBER"); else if(clicked_id=="add") document.getElementById("answer").value=val1+val2; else if(clicked_id=="sub") document.getElementById("answer").value=val1-val2; else if(clicked_id=="mul") document.getElementById("answer")....