0byt3m1n1
Path:
C:
/
wamp64
/
www
/
crop
/
Crops
/
[
Home
]
File: pests.php
<?php session_start(); $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = new mysqli($servername, $username, $password, $dbname); if (isset($_POST['submit'])) { $selectedCrop = $_POST['crop']; // Get the selected crop from the drop-down menu $pes=$_POST['Pests']; // Construct the SELECT query to retrieve the details based on the selected crop $selectCropQuery = "SELECT Name, Scientific_Name, Family FROM crop WHERE Name = '$selectedCrop' LIMIT 1;"; $selectpestsQuery="SELECT Pests, Psymptom, p_mng FROM crop WHERE Name = '$selectedCrop' AND Pests = '$pes' LIMIT 1;"; // Execute the queries $cropResult = mysqli_query($conn, $selectCropQuery) or die(mysqli_error($conn)); $pestsResult=mysqli_query($conn, $selectpestsQuery) or die(mysqli_error($conn)); // Display the results if (mysqli_num_rows($cropResult) > 0 && mysqli_num_rows($pestsResult) > 0) { $cropRow = mysqli_fetch_assoc($cropResult); $petsrow=mysqli_fetch_assoc($pestsResult); echo "<html>"; echo "<head>"; echo "<style>"; echo "body {"; echo " display: flex;"; echo " justify-content: center;"; echo " align-items: center;"; echo " min-height: 100vh;"; echo " background-color: #d3f5a4;"; echo "}"; echo ".container {"; echo " max-width: 1000px;"; echo " background-color: #fff;"; echo " padding: 20px;"; echo " border-radius: 8px;"; echo "}"; echo "</style>"; echo "</head>"; echo "<body>"; echo "<div class='container'>"; echo "<h2>PESTS</h2>"; echo "<p><strong> Name of Pests:</strong> " . $petsrow['Pests'] . "</p>"; echo "<p><strong> Symptoms:</strong> " . $petsrow['Psymptom'] . "</p>"; echo "<p><strong> Management:</strong> " . $petsrow['p_mng'] . "</p>"; echo "<h2>Images</h2>"; $selectImagesQuery1 = "SELECT img4 FROM crop WHERE Name = '$selectedCrop' AND Pests = '$pes'"; $imagesResult1 = mysqli_query($conn, $selectImagesQuery1) or die(mysqli_error($conn)); if (mysqli_num_rows($imagesResult1) > 0) { while ($imageRow = mysqli_fetch_assoc($imagesResult1)) { echo "<img src='images/" . $imageRow['img4'] . "' alt='Crop Image'>"; } } else { echo "No images found."; } echo "</div>"; echo "</body>"; echo "</html>"; } else { echo "No results found."; } } ?>