Guest User

Untitled

a guest
Dec 13th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.29 KB | None | 0 0
  1. P1.....................................................................
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <style>
  6. table,td,th {
  7. border : 1px solid black;
  8. width: 33%;
  9. text-align: center;
  10. background-color: darkgray;
  11. border-collapse: collapse;
  12. }
  13. table {
  14. margin: auto;
  15. }
  16. input {
  17. text-align: right;
  18. }
  19. </style>
  20.  
  21. <script type="text/javascript">
  22. function calc(clicked_id) {
  23. var val1 = parseFloat(document.getElementById("value1").value);
  24. var val2 = parseFloat(document.getElementById("value2").value);
  25. if(isNaN(val1)||isNaN(val2))
  26. alert("ENTER VALID NUMBER")
  27. else if(clicked_id == "add")
  28. document.getElementById("answer").value=val1+val2;
  29. else if(clicked_id == "sub")
  30. document.getElementById("answer").value=val1-val2;
  31. else if(clicked_id == "mul")
  32. document.getElementById("answer").value=val1*val2;
  33. else if(clicked_id == "div")
  34. document.getElementById("answer").value=val1/val2;
  35. }
  36.  
  37. function cls() {
  38. value1.value = "0";
  39. value2.value = "0";
  40. answer.value = "";
  41. }
  42. </script>
  43. </head>
  44. <body>
  45.  
  46. <table>
  47. <tr>
  48. <th colspan="4">SIMPLE CALCULATOR</th>
  49. </tr>
  50. <tr>
  51. <td>value1</td>
  52. <td><input type="text" id="value1" value="0"></td>
  53. <td>value2</td>
  54. <td><input type="text" id="value2" value="0"></td>
  55. </tr>
  56. <tr>
  57. <td><input type="button" value="Addition" id="add" onclick="calc(this.id)"></td>
  58. <td><input type="button" value="Subtraction" id="sub" onclick="calc(this.id)"></td>
  59. <td><input type="button" value="Multiplication" id="mul" onclick="calc(this.id)"></td>
  60. <td><input type="button" value="Division" id="div" onclick="calc(this.id)"></td>
  61. </tr>
  62. <tr>
  63. <td>Answer : </td>
  64. <td><input type="text" id="answer" value="" disabled></td>
  65. <td colspan="2"><input type="button" value="CLEAR ALL" onclick="cls()"></td>
  66. </tr>
  67. </table>
  68.  
  69. </body>
  70. </html>
  71.  
  72. P2....................................................................................................................
  73. <!DOCTYPE html>
  74. <html lang="en">
  75. <head>
  76. <style>
  77. table,tr,td {
  78. border : solid black;
  79. width: 33%;
  80. text-align: center;
  81. border-collapse: collapse;
  82. background-color: lightblue;
  83. }
  84. table {
  85. margin: auto;
  86. }
  87. </style>
  88.  
  89. <script>
  90. document.write("<table><tr><th colspan='3'> NUMBER FROM 0 TO 10 WITH THEIR SQUARES AND CUBES</th></tr>");
  91. document.write("<tr><td>Number</td><td>Square</td><td>Cube</td></tr>");
  92. for(var n=0;n<=10,n++) {
  93. document.write("<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>");
  94. }
  95. document.write("</table>")
  96. </script>
  97. </head>
  98. <body>
  99.  
  100. </body>
  101. </html>
  102.  
  103. P3.......................................................................................................................
  104. <!DOCTYPE html>
  105. <html lang="en">
  106. <head>
  107. <style>
  108. p {
  109. position: absolute;
  110. top: 50%;
  111. left: 50%;
  112. transform: translate(-50%,-50%);
  113. }
  114. </style>
  115. </head>
  116. <body>
  117. <p id="demo"></p>
  118. <script>
  119. var var1 = setInterval(inTimer, 1000);
  120. var fs =5;
  121. var ids = document.getElementById("demo");
  122. function inTimer() {
  123. ids.innerHTML = "TEXT GROWING";
  124. ids.setAttribute('style',"font-size:" + fs + "px; color:red");
  125. fs +=5;
  126. if(fs >=50) {
  127. clearInterval(var1);
  128. var var2 = setInterval(deTimer, 1000);
  129. }
  130. }
  131.  
  132. function deTimer() {
  133. fs -= 5;
  134. ids.innerHTML = "TEXT SHRINKING";
  135. ids.setAttribute('style',"font-size:" + fs + "px;color:blue");
  136. if(fs == 5) {
  137. clearInterval(var2);
  138. }
  139. }
  140. </script>
  141. </body>
  142. </html>
  143.  
  144. P4...................................................................................................................
  145. <!DOCTYPE html>
  146. <html lang="en">
  147. <head>
  148.  
  149. </head>
  150. <body>
  151. <script type="text/javascript">
  152. var str = prompt("Enter the input : ","");
  153. if(!isNaN(str)) {
  154. var num,rev=0,remainder;
  155. num=parseInt(str);
  156. while(num!=0) {
  157. remainder = num%10;
  158. num = parseInt(num/10);
  159. rev = rev*10+remainder;
  160. }
  161. alert("Reverse of " + str + " is " + rev);
  162. }
  163.  
  164. else {
  165. str = str.toUpperCase();
  166. for(var i=0;i<str.length;i++) {
  167. var chr = str.charAt(i);
  168. if(chr== 'A' || chr == 'E' || chr =='I' || chr == 'O' || chr == 'U') break;
  169. }
  170. if(i<str.length)
  171. alert("The position of the left most vowel is " + (i+1));
  172. else
  173. alert("No vowel found in the entered string");
  174. }
  175. </script>
  176. </body>
  177. </html>
  178.  
  179. P5................................................................................................................
  180. <?xml-stylesheet type="text/css" href="5.css" ?>
  181. <!DOCTYPE html>
  182. <html>
  183. <head>
  184. <h1>STUDENTS DESCRIPTION</h1>
  185. </head>
  186. <students>
  187. <student>
  188. <USN>USN : 1AY07CS001</USN>
  189. <name>NAME : SANTHOSH</name>
  190. <college>COLLEGE : ACIT</college>
  191. <branch>BRANCH : COMPUTER SCIENCE AND ENGINEERING</branch>
  192. <year>YEAR : 2007</year>
  193. <e-mail>E-Mail : santhosh@gmail.com</e-mail>
  194. </student>
  195. <student>
  196. <USN>USN : 1AY07IS001</USN>
  197. <name>NAME : MANORANJAn</name>
  198. <college>COLLEGE : ACIT</college>
  199. <branch>BRANCH : INFORMATION SCIENCE AND ENGINEERING</branch>
  200. <year>YEAR : 2007</year>
  201. <e-mail>E-Mail : manoranjan@gmail.com</e-mail>
  202. </student>
  203. <student>
  204. <USN>USN : 1AY07EC001</USN>
  205. <name>NAME : CHETHAN</name>
  206. <college>COLLEGE : ACIT</college>
  207. <branch>BRANCH : ELECTRONICS AND COMMUNICATIONS ENGINEERING</branch>
  208. <year>YEAR : 2007</year>
  209. <e-mail>E-Mail : chethan@gmail.com</e-mail>
  210. </student>
  211. </students>
  212. </html>
  213. .............................................................................................
  214. student {
  215. display: block;
  216. margin-top: 10px;
  217. color: navy;
  218. }
  219.  
  220. USN {
  221. display: block;
  222. margin-top: 10px;
  223. font-size: 14pt;
  224. color: red;
  225. }
  226.  
  227. name {
  228. display: block;
  229. margin-top: 20px;
  230. font-size: 14pt;
  231. color: blue;
  232. }
  233.  
  234. college {
  235. display: block;
  236. margin-top: 20px;
  237. font-size: 12pt;
  238. color: maroon;
  239. }
  240.  
  241. branch {
  242. display: block;
  243. margin-top: 20px;
  244. font-size: 12pt;
  245. color: purple;
  246. }
  247.  
  248. year {
  249. display: block;
  250. margin-top: 20px;
  251. font-size: 14pt;
  252. color: green;
  253. }
  254.  
  255. e-mail {
  256. display: block;
  257. margin-top: 20px;
  258. font-size: 12pt;
  259. color: blue;
  260. }
  261.  
  262. P6.......................................................................................................
  263. <?php
  264. print "<h3> REFRESH PAGE</h3>";
  265. $name = "Counter.txt";
  266. $file = fopen($name,"r");
  267. $hits = fscanf($file,"%d");
  268. fclose($file);
  269.  
  270. $hits[0]++;
  271. $file=fopen($name,"w");
  272. fprintf($file,"%d",$hits[0]);
  273. fclose($file);
  274. print("Total number of views : ".$hits[0]);
  275. ?>
  276.  
  277. P7.........................................................................................................
  278. <!DOCTYPE html>
  279. <html lang="en">
  280. <head>
  281. <meta http-equiv="refresh" content="1"/>
  282. <style>
  283. p {
  284. color : white;
  285. font-size:90px;
  286. position : absolute;
  287. top:50%;
  288. left:50%;
  289. transform:translate(-50%,-50%);
  290. }
  291. body {
  292. background-color:black;
  293. }
  294. </style>
  295. <p><?php
  296. echo date(" h:i:s A");
  297. ?></p>
  298. </head>
  299. </html>
  300.  
  301. P8A.............................................................................................................
  302. <?php
  303.  
  304. if(isset($_POST['sub']))
  305. {
  306. $txt1=$_POST['n1'];
  307. $txt2=$_POST['n2'];
  308. $oprnd=$_POST['sub'];
  309.  
  310. if($oprnd=="+")
  311. $res=$txt1+$txt2;
  312. else if($oprnd=="-")
  313. $res=$txt1-$txt2;
  314. else if($oprnd=="x")
  315. $res=$txt1*$txt2;
  316. else if($oprnd=="/")
  317. $res=$txt1/$txt2;
  318. }
  319. ?>
  320.  
  321. <form method="post" action="">
  322. Calculator
  323. <br>
  324. No1:<input name="n1" value="<?php echo $txt1; ?>">
  325. <br>
  326. No2:<input name="n2" value="<?php echo $txt2; ?>">
  327. <br>
  328. Res:<input name="res" value="<?php echo $res; ?>">
  329. <br>
  330. <input type="submit" name="sub" value="+">
  331. <input type="submit" name="sub" value="-">
  332. <input type="submit" name="sub" value="x">
  333. <input type="submit" name="sub" value="/">
  334. </form>
  335.  
  336. P8B...........................................................................................
  337. <?php
  338.  
  339. $a = array(array(1,2,3),array(4,5,6),array(7,8,9));
  340. $b = array(array(7,8,9),array(4,5,6),array(1,2,3));
  341.  
  342.  
  343. $m=count($a);
  344. $n=count($a[2]);
  345. $p=count($b);
  346. $q=count($b[2]);
  347.  
  348.  
  349. echo "the first matrix:"."<br/>";
  350. for ($row = 0;$row < $m; $row++)
  351. {
  352. for ($col = 0; $col < $n;$col++)
  353. echo "".$a[$row][$col];
  354. echo "<br/>";
  355. }
  356.  
  357. echo "the second matrix :"."<br/>";
  358. for ($row = 0;$row < $p; $row++)
  359. {
  360. for ($col = 0; $col < $q;$col++)
  361. echo " ".$b[$row][$col];
  362. echo "<br/>";
  363. }
  364. echo "the transpose for the first matrix is:"."<br/>";
  365. for ($row = 0; $row < $m; $row++)
  366. {
  367. for ($col = 0; $col < $n;$col++)
  368. echo "".$a[$col][$row];
  369. echo "<br/>";
  370. }
  371.  
  372. if(($m===$p) and ($n===$q))
  373. {
  374. echo "the addition of matrices is:"."<br/>";
  375. for ($row = 0; $row <3; $row++)
  376. {
  377. for ($col = 0; $col < 3; $col++)
  378. echo " ".$a[$row][$col]+$b[$row][$col]." ";
  379. echo "<br/>";
  380. }
  381. }
  382.  
  383. if($n===$p)
  384. {
  385. echo " The multiplication of matrices: <br/>";
  386. $result=array();
  387. for ($i=0; $i < $m; $i++)
  388. {
  389. for($j=0; $j<$q; $j++)
  390. {
  391. $result[$i][$j] = 0;
  392. for($k=0; $k <$n; $k++)
  393. $result[$i][$j] += $a[$i][$k] * $b[$k][$j];
  394. }
  395. }
  396.  
  397.  
  398. for ($row = 0; $row < $m; $row++)
  399. {
  400. for ($col = 0;$col < $q; $col++)
  401. echo " ".$result[$row][$col];
  402. echo "<br/>";
  403. }
  404.  
  405. }
  406. ?>
  407.  
  408. P9.......................................................................................
  409. <?php
  410.  
  411. $states = "Mississippi Alabama Texas Massachusetts Kansas";
  412. $statesArray = [];
  413. $states1 = explode(' ',$states);
  414. echo "Original Array : <br/>";
  415. foreach($states1 as $i =>$value)
  416. print("STATES[$i]=$value <br/>");
  417. foreach($states1 as $state) {
  418. if(preg_match('/x as $/',($state)))
  419. $statesArray[0] = ($state);
  420. }
  421.  
  422. foreach($states1 as $state) {
  423. if(preg_match('/^k.*s$/',($state)))
  424. $statesArray[1] = ($state);
  425. }
  426.  
  427. foreach($states1 as $state) {
  428. if(preg_match('/^M.*s$/',($state)))
  429. $statesArray[2] = ($state);
  430. }
  431.  
  432. foreach($states1 as $state) {
  433. if(preg_match('/a$/',($state)))
  434. $statesArray[3] = ($state);
  435. }
  436.  
  437. echo "<br><br> Resultant Array : <br>";
  438. foreach($statesArray as $array => $value)
  439. print("STATES[$array]=$value <br>");
  440. }
  441.  
  442. ?>
  443.  
  444. P10..............................................................................................................
  445. <!DOCTYPE html>
  446. <html lang="en">
  447. <body>
  448. <style>
  449. table,td,th {
  450. border:1px solid black;
  451. width:33%;
  452. text-align:center;
  453. border-collapse:collapse;
  454. background-color:lightblue;
  455. }
  456. table {
  457. margin:auto;
  458. }
  459. </style>
  460.  
  461. <?php
  462.  
  463. $servername = "localhost";
  464. $username = "root";
  465. $password = "root";
  466. $dbname = "weblab";
  467. $a = [];
  468.  
  469. $conn = $mysqli_connect($servername,$username,$password,$dbname);
  470.  
  471. if($conn->connect_error)
  472. die("Connection failed : ".$conn->connect_error);
  473.  
  474.  
  475. $sql = "SELECT * FROM student";
  476. $result = $conn->query($sql);
  477. echo "<br>";
  478. echo "<center>BEFORE SORTING</center>";
  479. echo "<table border='2'>";
  480. echo "<tr>";
  481. echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
  482. if($result->num_rows>0) {
  483. while($row = $result->fetch_assoc()) {
  484. echo "<tr>";
  485. echo "<td>".$row["usn"]."</td>";
  486. echo "<td>".$row["name"]."</td>";
  487. echo "<td>".$row["addr"]."</td></tr>";
  488. array_push($a,$row["usn"]);
  489. }
  490. }
  491.  
  492. else
  493. echo "Table is empty";
  494. echo "</table>";
  495.  
  496.  
  497. $n=count($a);
  498. $b=$a;
  499. for($i = 0; $i < ($n - 1); $i++) {
  500. $pos = $i;
  501. for($j = $i + 1; $j < $n; $j++) {
  502. if($a[$pos] > $a[$j])
  503. $pos = $j;
  504. }
  505. if($pos!=$i) {
  506. $temp = $a[$i];
  507. $a[$i] = $a[$pos];
  508. $a[$pos] = $temp;
  509. }
  510. }
  511.  
  512. $result = $conn->query($sql);
  513. if($result->num_rows>0) {
  514. while($row = $result->fetch_assoc()) {
  515. for($i = 0; $i < $n; $i++) {
  516. if($row["usn"] == $a[$i]) {
  517. $c[$i] = $row["name"];
  518. $d[$i] = $row["addr"];
  519. }
  520. }
  521. }
  522. }
  523.  
  524. echo "<br>";
  525. echo "<center>AFTER SORTING</center>";
  526. echo "<table border ='2'>";
  527. echo "<tr>";
  528. echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
  529.  
  530. for($i = 0; $i < $n; $i++) {
  531. echo "<tr>";
  532. echo "<td>".$a[$i]."</td>";
  533. echo "<td>".$c[$i]."</td>";
  534. echo "<td>".$d[$i]."</td></tr>";
  535. }
  536.  
  537. echo "</table>";
  538.  
  539. $conn.close();
  540.  
  541.  
  542. ?>
  543. </body>
  544. </html>
  545. ............................................................................................
Add Comment
Please, Sign In to add comment