SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang=PL >
  3. <head>
  4. <meta charset=utf-8>
  5. <title>Zmiana danych w bazie</title>
  6. </head>
  7. <body>
  8. <h2>Zmiana danych w bazie</h2>
  9. <a href=index.php>Index</a></br>
  10. <style> td { border: 1px solid black };</style>
  11.  
  12. <form action="" method="POST">
  13. <div>
  14. <input type="submit" name="p" value="Aktualizuj" />
  15. <input type="submit" name="m" value="Usuń" />
  16. </div>
  17. </form>
  18.  
  19. <?php
  20.     $p=mysqli_connect("localhost","root", "","test1");
  21.     if(!$p) echo "Nie działa.";
  22.    
  23.    
  24.     if(isset($_POST['p'])){
  25.     $sql="UPDATE tklienci set plec='k' where imie like '%a'";
  26.     mysqli_query($p,$sql);
  27.     $sql="UPDATE tklienci set plec='m' where imie not like '%a'";
  28.     mysqli_query($p,$sql);
  29.     }
  30.     if(isset($_POST['m'])){
  31.     $sql="UPDATE tklienci set plec='' where plec like 'k'";
  32.     mysqli_query($p,$sql);
  33.     $sql="UPDATE tklienci set plec='' where plec like 'm'";
  34.     mysqli_query($p,$sql);
  35.     }
  36.    
  37.     $sql="SELECT * from tklienci ORDER BY nazwisko";
  38.    
  39.     echo "<table>";
  40.     echo "<tr>";
  41.     echo "<td>Id</td><td>Imie</td><td>Nazwisko</td><td>Płeć</td>";
  42.     echo "</tr>";
  43.     $wnk=mysqli_query($p,$sql);
  44.     $w=mysqli_num_rows($wnk);
  45.     while($wers=mysqli_fetch_row($wnk)){
  46.     echo "<tr>";
  47.     echo "<td>$wers[0]</td><td>$wers[1]</td><td>$wers[2]</td><td>$wers[10]</td><br>";
  48.     echo "</tr>";
  49.     }
  50.    
  51.     echo "</table>";
  52.    
  53.    
  54. mysqli_close($p);
  55. ?>
  56. </body>
  57. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top