Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <?php
- $servername = "localhost";
- $username = "myusername";
- $password = "mypassword";
- $dbname = "mydatabase";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- if(!isset($_POST['country_type']) ||
- !isset($_POST['region_type']) ||
- !isset($_POST['wine_type']) ||
- !isset($_POST['vintage_type'])) {
- died('<p>We are sorry, but there appears to be a problem with the form you submitted.</p>');
- }
- $country_type = $_POST['country_type'];
- $region_type = $_POST['region_type'];
- $wine_type = $_POST['wine_type'];
- $vintage_type = $_POST['vintage_type'];
- $sql = "* FROM wp_winenotes
- WHERE Country = $country_type
- AND Wine = $wine_type
- AND Region = $region_type
- AND Vintage = $vintage_type;
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each selected row
- while($row = $result->fetch_assoc()) {
- $wine = iconv('ASCII', 'UTF-8//IGNORE', $row['Wine']);
- $note = iconv('ASCII', 'UTF-8//IGNORE', $row['Note']);
- echo "<br> id: ". $row['id']. " - Wine: " . $wine . "<br>Note: " . $note . "<br>";
- }
- } else {
- echo "0 results";
- }
- $conn->close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement