Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4. #container{
  5. width:800px;
  6. margin-left:auto;
  7. margin-right:auto;
  8. }
  9. #top{
  10. background-color:yellow;
  11. padding:10px;
  12. height:150px;
  13. }
  14. #l{
  15. background-color:orange;
  16. float:left;
  17. padding:10px;
  18. width:380px;
  19. height:300px;
  20. }
  21. #r{
  22. background-color:purple;
  23. padding:10px;
  24. float:left;
  25. width:380px;
  26. height:300px;
  27. }
  28. #b{
  29. background-color:blue;
  30. padding:10px;
  31. height:150px;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <div id="container">
  37. <div id="top">
  38. <form action=test2.php method=POST>
  39. Marka<input type=text name=marka><br>
  40. Model<input type=text name=model><br>
  41. Cena<input type=text name=cena><br>
  42. <input type=submit value=wyslij>
  43. </form>
  44. <?php
  45. if(isset($_POST['marka'])){
  46. $marka=$_POST['marka'];
  47. $model=$_POST['model'];
  48. $cena=$_POST['cena'];
  49. $pol=mysqli_connect("localhost","root","","samochody");
  50. $z="insert into auta values('$marka','$model','$cena')";
  51. $w=mysqli_query($pol,$z);
  52. mysqli_close($pol);
  53. }
  54. ?>
  55. </div>
  56. <div id="l">
  57. <?php
  58. $pol=mysqli_connect("localhost","root","","samochody");
  59. $z="select * from auta";
  60. $w=mysqli_query($pol,$z);
  61. $rekord=mysqli_fetch_assoc($w);
  62. while($rekord=mysqli_fetch_assoc($w)){
  63. echo $rekord['marka']." ".$rekord['model']." ".$rekord['cena']."<br>";
  64. }
  65. mysqli_close($pol);
  66. ?>
  67. </div>
  68. <div id="r">
  69. <form action=test2.php method=POST>
  70. Szukaj<input type=text name=szukaj><br>
  71. <input type=submit value=znajdz>
  72. </form>
  73. <?php
  74. if (isset($_POST['szukaj'])){
  75. $s=$_POST['szukaj'];
  76. $pol=mysqli_connect("localhost","root","","samochody");
  77. $z="select count(marka) as a from auta where marka='$s'";
  78. $w=mysqli_query($pol,$z);
  79. $rekord=mysqli_fetch_assoc($w);
  80. echo "Jest ".$rekord['a']." takich wartości";
  81. mysqli_close($pol);
  82. }
  83. ?>
  84. </div>
  85. <div id="b">
  86. CHUJ
  87. <?php
  88. $pol=mysqli_connect("localhost","root","","samochody");
  89. $z="select avg(cena) as a from auta";
  90. $w=mysqli_query($pol,$z);
  91. $a=mysqli_fetch_assoc($w)['a'];
  92. echo "Srednia cenowa to: ".$a;
  93. mysqli_close($pol);
  94. ?>
  95. </div>
  96. </div>
  97. </body>
  98. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement