Guest User

global

a guest
Dec 10th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.88 KB | None | 0 0
  1. /var/www/cgi-bin/2kl15cs019/tw
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <title>Simple calculator</title>
  7. </head>
  8. <body>
  9. <script type="text/javascript">
  10. var num1 = parseInt(prompt("enter first number"));
  11. var num2 = parseInt(prompt("enter Second number"));
  12. var op =prompt("enter the operator");
  13. switch(op)
  14. {
  15. case "+":document.write("the addition of 2 Numbers is:", num1+num2);
  16. break;
  17. case "-":document.write("the sub of 2 Numbers is:", num1-num2);
  18. break;
  19. case "*":document.write("the mul of 2 Numbers is:", num1*num2);
  20. break;
  21. case "/":if (num2==0) {
  22. document.write("unable to do operation");
  23. }
  24. else
  25. {
  26. document.write("the div of 2 Numbers is:", num1/num2);
  27.  
  28. }
  29. break
  30.  
  31. }
  32. </script>
  33.  
  34. </body>
  35. </html>
  36.  
  37. 2)
  38. <!DOCTYPE html>
  39. <html>
  40. <head>
  41. <title>Cubes And Squares</title>
  42.  
  43. </head>
  44. <body>
  45. <table align="Center" border="1">
  46. <tr><th>Number</th><th>Squares</th><th>Cubes</th></tr>
  47.  
  48. <script type="text/javascript">
  49. for(var n=0;n<10;n++){
  50. document.write("<tr><td>"+n+"</td><td>"+n*n+"</td><td>"+n*n*n+"</td></tr>");
  51. }
  52. </script>
  53. </table>
  54. </body>
  55. </html>
  56. 3)
  57. <html>
  58. <body>
  59. <p id="demo"></p>
  60. <script>
  61. var var1 = setInterval(inTimer, 1000);
  62. var size = 5;
  63. var ids = document.getElementById("demo");
  64. function inTimer() {
  65. ids.innerHTML = 'TEXT GROWING';
  66. ids.setAttribute('style', "font-size: " + size + "px; color: red");
  67. size += 5;
  68. if(size >= 50 ){
  69. clearInterval(var1);
  70. var2 = setInterval(deTimer,1000);
  71. }
  72. }
  73. function deTimer() {
  74. size -= 5;
  75. ids.innerHTML = 'TEXT SHRINKING';
  76. ids.setAttribute('style', "font-size: " + size + "px; color: blue");
  77. if(size == 5 ){
  78. clearInterval(var2);
  79. }
  80. }
  81. </script>
  82. </body>
  83. </html>
  84. 4)
  85. <html>
  86. <body>
  87. <script type="text/javascript">
  88. var str = prompt("Enter the Input","");
  89. if(isNaN(str))
  90. {
  91. str = str.toUpperCase();
  92. for(var i = 0; i < str.length; i++) {
  93. var chr = str.charAt(i);
  94. if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U')break;
  95. }
  96. if( i < str.length )
  97. alert("The position of the left most vowel is "+(i+1));
  98. else
  99. alert("No vowel found in the entered string");
  100. }
  101. else
  102. {
  103. var num,rev=0,remainder;
  104. num = parseInt(str);
  105. while(num!=0) {
  106. remainder = num%10;
  107. num = parseInt(num/10);
  108. rev = rev * 10 + remainder;
  109. }
  110. alert("Reverse of "+str+" is "+rev);
  111. }
  112. </script>
  113. </body>
  114. </html>
  115. 5)
  116. <?xml-stylesheet type="text/css" href="6.css" ?>
  117. <!DOCTYPE HTML>
  118. <html>
  119. <head>
  120. <h1> STUDENTS DESCRIPTION </h1>
  121. </head>
  122. <students>
  123. <student>
  124. <USN>USN : 1CG15CS001</USN>
  125. <name>NAME : SANTHOS</name>
  126. <college>COLLEGE : CIT</college>
  127. <branch>BRANCH : Computer Science and Engineering</branch>
  128. <year>YEAR : 2015</year>
  129. <e-mail>E-Mail : santosh@gmail.com</e-mail>
  130. </student>
  131. <student>
  132. <USN>USN : 1CG15IS002</USN>
  133. <name>NAME : MANORANJAN</name>
  134. <college>COLLEGE : CITIT</college>
  135. <branch>BRANCH : Information Science and Engineering</branch>
  136. <year>YEAR : 2015</year>
  137. <e-mail>E-Mail : manoranjan@gmail.com</e-mail>
  138. </student>
  139. <student>
  140. <USN>USN : 1CG15EC101</USN>
  141. <name>NAME : CHETHAN</name>
  142. <college>COLLEGE : CITIT</college>
  143. <branch>BRANCH : Electronics and Communication Engineering
  144. </branch>
  145. <year>YEAR : 2015</year>
  146. <e-mail>E-Mail : chethan@gmail.com</e-mail>
  147. </student>
  148. </students>
  149. </html>
  150.  
  151. 6)
  152. <?php
  153. print "<h3> REFRESH PAGE </h3>";
  154. $name="counter.txt";
  155. $file = fopen($name,"r");
  156. $hits= fscanf($file,"%d");
  157. fclose($file);
  158. $hits[0]++;
  159. $file = fopen($name,"w");
  160. fprintf($file,"%d",$hits[0]);
  161. fclose($file);
  162. print "Total number of views: ".$hits[0];
  163. ?>
  164.  
  165. 7)<html>
  166. <head>
  167. <meta http-equiv="refresh" content="1"/>
  168. <style>
  169. p {
  170. color:white;
  171. font-size:90px;
  172. position: absolute;
  173. top: 50%;
  174. left: 50%;
  175. transform: translate(-50%, -50%);
  176. }
  177. body{background-color:red;}
  178. </style>
  179. <p> <?php echo date(" h: m : s A");?> </p>
  180. </head>
  181. </html>
  182. 8a)
  183. <html>
  184. <head>
  185. <style>
  186. table, td, th
  187. {
  188. border: 1px solid black;
  189. width: 35%;
  190. text-align: center;
  191. background-color: DarkGray;
  192. }
  193. table { margin: auto; }
  194. input,p { text-align:right; }
  195. </style>
  196. </head>
  197. <body>
  198. <form method="post">
  199. <table>
  200. <caption><h2> SIMPLE CALCULATOR </h2></caption>>
  201. <tr><td>First Number:</td><td><input type="text" name="num1" /></td>
  202. <td rowspan="2"><input type="submit" name="submit"
  203. value="calculate"></td></tr>
  204. <tr><td>Second Number:</td><td><input type="text"
  205. name="num2"/></td></tr>
  206. </form>
  207. <?php
  208. if(isset($_POST['submit']))
  209. {
  210. $num1 = $_POST['num1'];
  211. $num2 = $_POST['num2'];
  212. if(is_numeric($num1) andis_numeric($num1) )
  213. {
  214. echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
  215. echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
  216. echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>";
  217. echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
  218. echo "</table>";
  219. }
  220. else
  221. {
  222. echo"<script type='text/javascript' > alert(' ENTER VALID NUMBER');</script>";
  223. }
  224. }
  225.  
  226. ?>
  227. </body>
  228. </html>
  229.  
  230. 8b)<?php
  231. $a = array(array(1,2,3),array(4,5,6),array(7,8,9));
  232. $b = array(array(7,8,9),array(4,5,6),array(1,2,3));
  233. $m=count($a);
  234. $n=count($a[2]);
  235. $p=count($b);
  236. $q=count($b[2]);
  237. echo "the first matrix :"."<br/>";
  238. for ($row = 0; $row < $m; $row++) {
  239. for ($col = 0; $col < $n; $col++)
  240. echo " ".$a[$row][$col];
  241. echo "<br/>";
  242. }
  243. echo "the second matrix :"."<br/>";
  244. for ($row = 0; $row < $p; $row++) {
  245. for ($col = 0; $col < $q; $col++)
  246. echo " ".$b[$row][$col];
  247. echo "<br/>";
  248. }
  249. echo "the transpose for the first matrix is:"."<br/>";
  250.  
  251. for ($row = 0; $row < $m; $row++) {
  252. for ($col = 0; $col < $n; $col++)
  253. echo " ".$a[$col][$row];
  254. echo "<br/>";
  255. }
  256. if(($m===$p) and ($n===$q)) {
  257. echo "the addition of matrices is:"."<br/>";
  258. for ($row = 0; $row < 3; $row++) {
  259. for ($col = 0; $col < 3; $col++)
  260. echo " ".$a[$row][$col]+$b[$row][$col]." ";
  261. echo "<br/>";
  262. }
  263. }
  264. if($n===$p){
  265. echo " The multiplication of matrices: <br/>";
  266. $result=array();
  267. for ($i=0; $i < $m; $i++) {
  268. for($j=0; $j < $q; $j++){
  269. $result[$i][$j] = 0;
  270. for($k=0; $k < $n; $k++)
  271. $result[$i][$j] += $a[$i][$k] * $b[$k][$j];
  272. }
  273. }
  274. for ($row = 0; $row < $m; $row++) {
  275. for ($col = 0; $col < $q; $col++)
  276. echo " ".$result[$row][$col];
  277. echo "<br/>";
  278. }
  279. }
  280.  
  281. ?>
  282.  
  283. 9)<?php
  284. $states = "Mississippi Alabama Texas Massachusetts Kansas";
  285. $statesArray = [];
  286. $states1 = explode(' ',$states);
  287. foreach($states1 as $state) {
  288. if(preg_match( '/xas$/', ($state)))
  289. $statesArray[0] = ($state);
  290. }
  291. foreach($states1 as $state) {
  292. if(preg_match( '/Kansas$/', ($state)))
  293. $statesArray[1] = ($state);
  294. }
  295. foreach($states1 as $state) {
  296. if(preg_match( '/Massachusetts$/', ($state)))
  297. $statesArray[2] = ($state);
  298. }
  299. foreach($states1 as $state) {
  300. if(preg_match( '/Alabama$/', ($state)))
  301. $statesArray[3] = ($state);
  302. }
  303. foreach ( $statesArray as $element => $value ){
  304. print( $value." is the element ". $element."<br/>");
  305. }
  306. ?>
  307.  
  308. 10)mysql -u root
  309. mysql>create database 2kl15cs019
  310. mysql>use 2kl15cs019
  311. create table student(usn varchar(10),name varchar(20),address varchar(20));
  312. insert into student values('19','daya','bijapur')
  313. <html>
  314. <body>
  315. <style>
  316. table, td, th
  317. {
  318. border: 1px solid black;
  319. width: 33%;
  320. text-align: center;
  321. border-collapse:collapse;
  322. background-color:lightblue;
  323. }
  324. table { margin: auto; }
  325. </style>
  326. <?php
  327. $servername = "localhost";
  328. $username = "root";
  329. $password = "";
  330. $dbname = "weblab";
  331. $a=[];
  332.  
  333. $conn = mysqli_connect($servername, $username, $password, $dbname);
  334. // Check connection and return an error description from the last connection error, if any
  335. if ($conn->connect_error)
  336. die("Connection failed: " . $conn->connect_error);
  337. $sql = "SELECT * FROM student";
  338. // performs a query against the database
  339. $result = $conn->query($sql);
  340. echo "<br>";
  341. echo "<center> BEFORE SORTING </center>";
  342. echo "<table border='2'>";
  343. echo "<tr>";
  344. echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
  345. if ($result->num_rows> 0)
  346. {
  347. // output data of each row and fetches a result row as an
  348.  
  349. while($row = $result->fetch_assoc()){
  350. echo "<tr>";
  351. echo "<td>". $row["usn"]."</td>";
  352.  
  353. echo "<td>". $row["name"]."</td>";
  354. echo "<td>". $row["address"]."</td>";
  355. echo "</tr>";
  356. array_push($a,$row["usn"]);
  357. }
  358. }
  359. else
  360. echo "Table is Empty";
  361. echo "</table>";
  362. $n=count($a);
  363. $b=$a;
  364. for ( $i = 0 ; $i< ($n - 1) ; $i++ )
  365. {
  366. $pos= $i;
  367. for ( $j = $i + 1 ; $j < $n ; $j++ ) {
  368. if ( $a[$pos] > $a[$j] )
  369. $pos= $j;
  370. }
  371. if ( $pos!= $i ) {
  372. $temp=$a[$i];
  373. $a[$i] = $a[$pos];
  374. $a[$pos] = $temp;
  375. }
  376. }
  377. $c=[];
  378. $d=[];
  379. $result = $conn->query($sql);
  380. if ($result->num_rows> 0)// output data of each row
  381. {
  382. while($row = $result->fetch_assoc()) {
  383. for($i=0;$i<$n;$i++) {
  384. if($row["usn"]== $a[$i]) {
  385. $c[$i]=$row["name"];
  386. $d[$i]=$row["address"];
  387. }
  388. }
  389. }
  390. }
  391. echo "<br>";
  392. echo "<center> AFTER SORTING <center>";
  393. echo "<table border='2'>";
  394. echo "<tr>";
  395. echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
  396. for($i=0;$i<$n;$i++) {
  397. echo "<tr>";
  398. echo "<td>". $a[$i]."</td>";
  399. echo "<td>". $c[$i]."</td>";
  400.  
  401. echo "<td>". $d[$i]."</td></tr>";
  402. }
  403. echo "</table>";
  404.  
  405. $conn->close();
  406. ?>
  407. </body>
  408. </html>
Add Comment
Please, Sign In to add comment