Advertisement
Guest User

Untitled

a guest
Jan 7th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. $server='mysql.cba.pl';
  6. $username='tfrymus';
  7. $password='Mpkfa1234';
  8.  
  9.  
  10. $pol=mysql_connect($server, $username, $password);
  11.  
  12. if($pol)
  13. {
  14. echo "POLACZONO Z BAZA DANYCH ";
  15. $baza=mysql_select_db('tfrymus');
  16.  
  17. if($baza)
  18. {
  19.  
  20. $zap=mysql_query("SELECT * FROM dane");
  21.  
  22. if($zap)
  23. {
  24. $query = "SELECT * FROM dane";
  25. $szukaj = $_GET['kryteria'];
  26. $where = " nazwisko LIKE '%$szukaj%'";
  27.  
  28. if (!empty($where))
  29. $query = $query . " WHERE $where";
  30.  
  31.  
  32. $zapytanie = "SELECT COUNT(*) FROM dane WHERE $where";
  33. $pomoc=mysql_query ($zapytanie);
  34. $liczba_wyn=mysql_result($pomoc, 0);
  35. echo $liczba_wyn;
  36. echo " - plik wyniki.php";
  37.  
  38. $liczba_na_str=10;
  39. $liczba_str=$liczba_wyn/$liczba_na_str;
  40. $liczba_str=ceil($liczba_str);
  41.  
  42. if (isset($_GET['str']))
  43. $str=$_GET['str'];
  44. else $str=1;
  45.  
  46. $pomin=($str-1)*$liczba_na_str;
  47.  
  48. $zapytanie= "SELECT * FROM dane WHERE $where LIMIT $pomin, $liczba_na_str";
  49.  
  50.  
  51. $wyniki=mysql_query($zapytanie);
  52.  
  53.  
  54. echo'<table><tr><th>ImiÄ™</th><th>Nazwisko</th><th>plec</th><th>nazwisko panienskie</th><th>email</th><th>kod</th></tr>';
  55. while($row=mysql_fetch_array($wyniki))
  56. {
  57. echo "<tr><td>{$row['imie']}</td><td>{$row['nazwisko']}</td><td>{$row['plec']}</td><td>{$row['naz_pan']}</td><td>{$row['email']}</td><td>{$row['kod']}</td></tr>";
  58. }
  59. echo'</table>';
  60.  
  61.  
  62.  
  63.  
  64.  
  65. $linki=' ';
  66.  
  67. if ($str>1)
  68. {
  69. $linki=$linki. '<a href="'.$_SERVER['PHP_SELF']. '?strona=4&szukaj=&str='.($str-1).'"><-</a>';
  70. }
  71. else
  72. {
  73. $linki=$linki. '<-';
  74. }
  75.  
  76. for($i=1; $i<=$liczba_str; $i++)
  77. {
  78. if ($str==$i)
  79. {
  80. $linki=$linki.' '.$i;
  81. }
  82. else
  83. {
  84. $linki=$linki. '<a href="'.$_SERVER['PHP_SELF']. '?strona=4&szukaj=&str='.$i.'">'.$i.'</a>';
  85. }
  86. }
  87.  
  88. if ($str<$liczba_str)
  89. {
  90. $linki=$linki. '<a href="'.$_SERVER['PHP_SELF']. '?strona=4&szukaj=&str=2'.($str+1).'">-></a>';
  91. }
  92. else
  93. {
  94. $linki=$linki. '->';
  95. }
  96.  
  97.  
  98.  
  99. echo $linki;
  100.  
  101. }
  102. else
  103. echo " nie weszlo w zap".mysql_error();
  104. }
  105. else
  106. echo"cos nie tak";
  107.  
  108.  
  109.  
  110. }
  111. else
  112. echo "NIE POLACZONO Z BAZA DANYCH";
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129. mysql_close();
  130.  
  131. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement