Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <div class="container" style="text-align: center;color:#55555">
  2.             <h1>Išverskite žodžius į lietuvių kalbą:</h1>
  3.             <?php
  4.                 $servername = "localhost";
  5.                 $username = "manant";
  6.                 $password = "eiPh3Ahx8ohTh8qu";
  7.                 $dbname = "manant";
  8.  
  9.                 //Connection
  10.                 $conn = new mysqli($servername, $username, $password, $dbname);
  11.  
  12.                 //Check
  13.                 if ($conn->connect_error) {
  14.                     die("Connection failed: " . $conn->connect_error);
  15.                 }
  16.  
  17.                 $sql = "SELECT * FROM politephrases";
  18.                 $result = $conn->query($sql);
  19.  
  20.                 //Create an empty array
  21.                 $array = array();
  22.  
  23.                 if ($result->num_rows > 0) {
  24.                 // output data of each row
  25.                     while($row = $result->fetch_assoc()) {
  26.                         $array[] = $row;
  27.                     }
  28.                 }
  29.  
  30.                 $n = sizeof($array);
  31.                 //shuffle($array);
  32.                 for ($i = 0; $i < $n; $i++) {
  33.                     echo $array[$i]['id'] ." ";
  34.                     echo $array[$i]['word'] ." ";
  35.                     echo $array[$i]['transl'];
  36.                     echo "<br>";
  37.                 }
  38.                 echo "<br>";
  39.                
  40.                 $i=0;
  41.                 echo "<h2>Žodis: </h2>";
  42.                 echo $array[$i]['word'];
  43.                
  44.            
  45.                 if(!empty($_POST)){
  46.                     $transl = $_POST['translation'];
  47.                     if($array[$i]['transl'] == $transl){
  48.                         echo "<br> PUIKU";
  49.                         $i = $i + 1;
  50.                     }
  51.                     else {
  52.                         echo "<br> NETEISINGAI";   
  53.                     }
  54.                 }
  55.                 else {
  56.                     echo "Nieko neįvesta.";   
  57.                 }
  58.                
  59.                
  60.                
  61.                 $conn->close();
  62.  
  63.             ?>
  64.            
  65.             <form name="tr" method="post" action="polite-phrases-eng.php">
  66.                 <br>
  67.                 <input type="text" id="translation" name="translation" placeholder="Įrašykite žodžio vertimą">
  68. <!--                <input type="text" value="" name="translation" id="translation">-->
  69.                 <input type="submit" name="submit1" value="Vykdyti">
  70.             </form>
  71.                
  72.         </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement