Guest User

Untitled

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