Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- #header {
- background-color:black;
- color:white;
- text-align:center;
- padding:8px;
- font-family:Zawgyi-One;
- }
- #nav {
- line-height:30px;
- background-color:#aaa;
- height:450px;
- width:100px;
- float:right;
- padding:5px;
- font-family:Zawgyi-One;
- }
- #form {
- margin-left: 80px;
- margin-top:40px;
- font-family:Zawgyi-One;
- }
- body {
- background-color: white;
- }
- </style>
- </head>
- <body>
- <div id="header">
- <h3>Online Dictionary</h3>
- </div>
- <div id="nav">
- Home<br>
- StackOverflow<br>
- Github
- </div>
- </body>
- </html>
- <html>
- <head> <meta charset="UTF-8"> </head>
- <body {background-color: lightblue;} style="font-family:Zawgyi-One;">
- <div id="form">
- <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
- Search english word: <input type="text" name="english">
- <input type="submit">
- </form>
- </div>
- <div style="font-family:Zawgyi-One;" >
- <?php
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- // collect value of input field
- $english = $_REQUEST['english'];
- if (empty($english)) {
- echo "Search english word is empty";
- } else {
- echo "<div id='form'> $english</div>";
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "engmmdb";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM dictionarytb where english like '".$english."%'" ;
- //$sql = "SELECT * FROM dictionarytb where english like '".$english."%'";
- //echo $sql."<br>";
- $result = mysqli_query($conn, $sql);
- //echo $result."<br>";
- if (mysqli_num_rows($result) > 0) {
- $myfile = fopen("dicterror.log", "a") or die("Unable to open file!");
- fwrite($myfile, mysqli_num_rows($result));
- //fclose($myfile);
- $rowcount = mysqli_num_rows($result);
- echo "<div id='form'> Found $rowcount word(s)</div>";
- // output data of each row
- $response["result"]=array();
- while($row = mysqli_fetch_assoc($result)) {
- //$str = iconv('windows-1251', 'utf-8', $str);
- echo "<div id='form'> id: " . $row["_id"]. " - English: " . $row["english"]. " " . $row["grammar"]." " . $row["myanmar"]. " " . $row["example"]."<br></div>";
- //echo "id: " . $row["_id"]. " - English: " . $row["english"]. " " . $row["grammar"]." " . utf8_encode($row["myanmar"]). " " . $row["example"]."<br>";
- fwrite($myfile,utf8_encode($row["myanmar"]));
- $found = array();
- $found["english"]=$row["english"];
- $found["myanmar"]=$row["myanmar"];
- array_push($response["result"],$found);
- }
- $response["success"]=1;
- //echo json_encode($response);
- } else {
- echo "0 results";
- $response["success"]=0;
- //echo json_encode($response);
- }
- fclose($myfile);
- mysqli_close($conn);
- }
- }
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement