12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title> KODY POCZTOWE </title> <link rel ="stylesheet" href="style.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> </head> <body> <?php $_SESSION['click'] = true; session_start(); if($_SESSION['click']==true){ $sql = "SELECT * FROM tabela order by miejscowość desc LIMIT 100"; $_SESSION['click'] = false; } else if($_SESSION['click']==false){ $sql = "SELECT * FROM tabela order by miejscowość asc LIMIT 100"; $_SESSION['click'] = true; } $servername = "localhost"; $username = "root"; $password = ""; $dbname ="kody_p"; $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { die("Błąd połączenia: " . mysqli_connect_error()); } echo "<table class='table table-striped table-dark'> <tr> <th scope='col'> KOD POCZTOWY </th> <th scope='col'> ADRES </th> <form method='post'> <th scope='col'> MIEJSCOWOŚĆ <button>Sort</button> </th> </form> <th scope='col'> WOJEWÓDZTWO </th> <th scope='col'> POWIAT </th> </tr>"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { echo "<tr> <td> ". $row["KOD POCZTOWY"] ." </td> <td> ". $row["ADRES"] ." </td> <td> ". $row["MIEJSCOWOŚĆ"] ." </td> <td> ". $row["WOJEWÓDZTWO"] ." </td> <form action='usun.php' method='get'> <td> ". $row["POWIAT"] ." <a href='usun.php?id={$row['id']}'>usuń</a><button>edytuj</button></td> </form> </tr>"; } echo "</table>"; } else { echo "Brak wyników."; } ?> </body> </html> |