SHARE
TWEET

Untitled

a guest May 23rd, 2018 88 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. <link rel="stylesheet" type="text/css" href="style.css">
  6. <title>TiTLe</title>
  7. </head>
  8. <body>
  9. <form action="index.php" method="GET">
  10. a:<input type="number" name="a"><br>
  11. b:<input type="number" name="b"><br>
  12. <input type="submit" value="wo">
  13. </form>
  14. <?php
  15. function suma($x, $y){
  16.     $s=$x+$y;
  17.     return $s;
  18. }
  19.     //polaczenie z baza danych:
  20.     $serverName="localhost";
  21.     $userName="root";
  22.     $pass="";
  23.     $dbName="prostokat";
  24. if(isset($_GET["a"]) && $_GET["a"]!="" && $_GET["b"]!=""){
  25.    
  26.  
  27. $conn=mysqli_connect($serverName,$userName,$pass,$dbName);
  28. if(!$conn) {
  29.     die("blad polaczenia".mysqli_connect_error());
  30. }    
  31.     $sql="insert into dane (a,b) values(".$_GET["a"].",".$_GET["b"].");";
  32.     $wynik=mysqli_query($conn,$sql);
  33.     if(!$wynik){ die ("wynik zapytania blad");}
  34.     else{
  35.     $wynik=suma($_GET["a"],$_GET["b"]);
  36.     echo "<br> Wynik działania funkcji suma:".$wynik."<br>Zawartosc tabeli z bazy danych<br>";
  37.         $str="<table border=1>";
  38.         $str.="<tr><td>id</td><td>a</td><td>b</td><tr>";
  39.         $sql="select *from dane;";
  40.         $wynik=mysqli_query($conn,$sql);
  41.         if($wynik){
  42.             if(mysqli_num_rows($wynik)>0){
  43.                 while ($wiersz=mysqli_fetch_assoc($wynik)){
  44.                     $str.="<tr><td>".$wiersz["id"]."</td><td>".$wiersz["a"]."</td><td>".
  45.                         $wiersz["b"]."</td></tr>";
  46.                 }
  47.             }
  48.         }
  49.   $str.="</table";
  50.         echo $str;
  51. }
  52.     mysqli_close($conn);
  53. }
  54. ?>
  55. </body>
  56. </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
 
Top