Advertisement
aungwinhtut

dictionary

Jun 16th, 2016
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 3.19 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <style>
  6. #header {
  7.     background-color:black;
  8.     color:white;
  9.     text-align:center;
  10.     padding:8px;
  11.     font-family:Zawgyi-One;
  12. }
  13. #nav {
  14.     line-height:30px;
  15.     background-color:#aaa;
  16.     height:450px;
  17.     width:100px;
  18.     float:right;
  19.     padding:5px;
  20.     font-family:Zawgyi-One;
  21. }
  22.  
  23. #form {
  24.     margin-left: 80px;
  25.     margin-top:40px;
  26.     font-family:Zawgyi-One;
  27. }
  28.  
  29. body {
  30.  
  31.     background-color: white;
  32. }
  33.  
  34.  
  35. </style>
  36. </head>
  37. <body>
  38.     <div id="header">
  39.         <h3>Online Dictionary</h3>
  40.        
  41.     </div>
  42.     <div id="nav">
  43.         Home<br>
  44.         StackOverflow<br>
  45.         Github
  46.     </div>
  47.     </body>
  48. </html>
  49.  
  50.  
  51. <html>
  52.     <head> <meta charset="UTF-8"> </head>
  53.     <body {background-color: lightblue;} style="font-family:Zawgyi-One;">
  54.         <div id="form">
  55.         <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
  56.             Search english word: <input type="text" name="english">
  57.             <input type="submit">
  58.         </form>
  59.     </div>
  60.         <div  style="font-family:Zawgyi-One;" >
  61.  
  62. <?php
  63. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  64.    // collect value of input field
  65.    $english = $_REQUEST['english'];
  66.    if (empty($english)) {
  67.        echo "Search english word is empty";
  68.    } else {
  69.        echo "<div id='form'> $english</div>";
  70.         $servername = "localhost";
  71.         $username = "root";
  72.         $password = "";
  73.         $dbname = "engmmdb";
  74.  
  75.         // Create connection
  76.         $conn = mysqli_connect($servername, $username, $password, $dbname);
  77.         // Check connection
  78.         if (!$conn) {
  79.             die("Connection failed: " . mysqli_connect_error());
  80.         }
  81.  
  82.         $sql = "SELECT * FROM dictionarytb where english like '".$english."%'" ;
  83.  
  84.         //$sql = "SELECT * FROM dictionarytb where english like '".$english."%'";
  85.         //echo $sql."<br>";
  86.         $result = mysqli_query($conn, $sql);
  87.         //echo $result."<br>";
  88.         if (mysqli_num_rows($result) > 0) {
  89.  
  90.             $myfile = fopen("dicterror.log", "a") or die("Unable to open file!");          
  91.             fwrite($myfile, mysqli_num_rows($result));
  92.             //fclose($myfile);
  93.             $rowcount = mysqli_num_rows($result);
  94.             echo "<div id='form'> Found $rowcount word(s)</div>";
  95.             // output data of each row
  96.             $response["result"]=array();
  97.             while($row = mysqli_fetch_assoc($result)) {
  98.                 //$str = iconv('windows-1251', 'utf-8', $str);
  99.                
  100.                 echo "<div id='form'> id: " . $row["_id"]. " - English: " . $row["english"]. " " . $row["grammar"]." " . $row["myanmar"]. " " . $row["example"]."<br></div>";
  101.                 //echo "id: " . $row["_id"]. " - English: " . $row["english"]. " " . $row["grammar"]." " . utf8_encode($row["myanmar"]). " " . $row["example"]."<br>";
  102.  
  103.                 fwrite($myfile,utf8_encode($row["myanmar"]));
  104.  
  105.                 $found = array();
  106.                 $found["english"]=$row["english"];
  107.                 $found["myanmar"]=$row["myanmar"];
  108.                 array_push($response["result"],$found);
  109.  
  110.             }
  111.             $response["success"]=1;
  112.             //echo json_encode($response);
  113.         } else {
  114.             echo "0 results";
  115.             $response["success"]=0;
  116.             //echo json_encode($response);
  117.         }
  118.         fclose($myfile);
  119.         mysqli_close($conn);
  120.  
  121.        
  122.     }
  123. }
  124. ?>
  125. </div>
  126.  
  127. </body>
  128. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement