Advertisement
Guest User

Untitled

a guest
Jan 8th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "id3352873_superbaza";
  4. $serveradress = "localhost";
  5. $username = "id3352873_tony";
  6. $password = "lollol22";
  7.  
  8. //$pol = new mysqli($servername, $username, $password);
  9. $pol=mysqli_connect($serveradress, $username, $password);
  10.  
  11. if($pol)
  12. {
  13. //echo "udalo sie1";
  14. $baza=mysqli_select_db($pol,$servername);
  15. if($baza)
  16. {
  17.  
  18. $wybierz = "SELECT id,imie,nazwisko,plec,nazwisko_panienskie,email,kod_pocztowy FROM formularz";
  19.  
  20. $zap=mysqli_query($pol, $wybierz);
  21. if($zap)
  22. {
  23. $na_stronie = 4;
  24. $tabela = 'formularz';
  25. $query = "SELECT COUNT(id) FROM $tabela";
  26. $wynik = mysqli_query($pol, $query);
  27. $a = mysqli_fetch_row($wynik);
  28. $liczba_wpisow = $a[0];
  29. $liczba_stron = ceil($liczba_wpisow / $na_stronie);
  30.  
  31. if (isset($_GET['str'])) {
  32. if ($_GET['str'] < 1 || $_GET['str'] > $liczba_stron) $str = 1;
  33. else $str = $_GET['str'];
  34. }
  35. else $str = 1;
  36.  
  37. $od = $na_stronie * ($str - 1);
  38. $query = "SELECT * FROM $tabela LIMIT $od , $na_stronie";
  39. $wynik = mysqli_query($pol, $query);
  40.  
  41. echo '<table border="1">';
  42. if(isset($_GET["strona"])) {
  43. $str=$_GET["strona"];
  44.  
  45. '<tr>';
  46. }
  47. echo '<td>'. '<b>Id</b>' .
  48. '</td><td>'. '<b>Imie</b>'.
  49. '</td><td>'. '<b>Nazwisko</b>' .
  50. '</td><td>'. '<b>Plec</b>' .
  51. '</td><td>'. '<b>Panienskie</b>' .
  52. '</td><td>'. '<b>Email</b>' .
  53. '</td><td>'. '<b>kod</b>' .
  54. '</td></tr>';
  55. while ($wiersz = mysqli_fetch_array($wynik))
  56. {
  57. echo'<tr>';
  58. echo'</td><td>'. $wiersz['id'] .
  59. '</td><td>'. $wiersz['imie'] .
  60. '</td><td>'. $wiersz['nazwisko'] .
  61. '</td><td>'. $wiersz['plec'] .
  62. '</td><td>'. $wiersz['nazwisko_panienskie'] .
  63. '</td><td>'. $wiersz['email'] .
  64. '</td><td>'. $wiersz['kod_pocztowy'] .
  65. '</td></tr>';
  66. }
  67. echo '</table>';
  68.  
  69. //mysqli_close($pol);
  70.  
  71.  
  72. if ($liczba_wpisow > $na_stronie) {
  73. $poprzednia = $str - 1;
  74. $nastepna = $str + 1;
  75.  
  76. $strona=$_GET['strona'];
  77. if ($poprzednia > 0) {
  78. echo '<a id="POPRZEDNIA" href="index.php%20?strona='.$strona.'&str='.$poprzednia.'"><- </a>';
  79. }
  80. else
  81. echo '<- ';
  82.  
  83. for($i=1; $i<1+$liczba_stron; $i++)
  84. {
  85. if($i != $_GET['str'])
  86. echo '<a id="stronka" href="index.php%20?strona='.$strona.'&str='.$i.'">'.$i.' </a>';
  87. else
  88. echo '<span style="color: red;">'.$i.' </span>';
  89. }
  90.  
  91.  
  92.  
  93. if ($nastepna <= $liczba_stron) {
  94. echo '<a id="NASTEPNA" href="index.php%20?strona='.$strona.'&str='.$nastepna.'">-></a>';
  95. }
  96. else
  97. echo "->";
  98.  
  99. }
  100.  
  101. }
  102. else
  103. {
  104. echo "blad zapytania".mysqli_error($pol);
  105. }
  106.  
  107. }
  108. else
  109. {
  110. echo "Połączenie z bazą nieudane<br>";
  111. mysqli_close();
  112. }
  113. }
  114. else
  115. {
  116. echo "Połączenie z serwerem nieudane<br>";
  117. mysqli_close();
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124. // $result=mysqli_query($pol, "SELECT count(*) as total from formularz");
  125. // $data=mysqli_fetch_assoc($result);
  126. // echo $data['total'];
  127.  
  128. // $zapytanie="SELECT count(*) from formularz;";
  129. // $pomoc=mysqli_query($pol, $zapytanie);
  130.  
  131.  
  132.  
  133.  
  134.  
  135. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement