Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $text = $_POST["text"];
- $select = $_POST["select"];
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "Studenci";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if($select=="*")
- {
- $sql = "SELECT * FROM Studenci";
- }
- if($select=="imie")
- {
- $sql = "SELECT id, imie, nazwisko FROM Studenci WHERE imie='" . $text . "'";
- }
- if($select=="nazwisko")
- {
- $sql = "SELECT id, imie, nazwisko FROM Studenci WHERE nazwisko='" . $text . "'";
- }
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- echo "id: " . $row["id"]. " - Imie: " . $row["imie"]. " - Nazwisko: " . $row["nazwisko"]. "<br>";
- }
- } else {
- echo "0 wyników";
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement