0byt3m1n1
Path:
C:
/
wamp64
/
www
/
Crops
/
[
Home
]
File: nutri.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 // Construct the SELECT query to retrieve the details based on the selected crop $selectQuery = "SELECT Name,Nutrient, Symptoms, Management, img2 FROM crop WHERE Name = '$selectedCrop'"; // Execute the query $result = mysqli_query($conn, $selectQuery) or die(mysqli_error($conn)); // Display the results if (mysqli_num_rows($result) > 0) { 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'>"; while ($row = mysqli_fetch_assoc($result)) { echo "<h2> Details of" . $row['Name'] . "</h2>"; echo "<h2>Nutrient Details</h2>"; echo "<p><strong>Nutrient Name:</strong> " . $row['Nutrient'] . "</p>"; echo "<p><strong>Symptoms:</strong> " . $row['Symptoms'] . "</p>"; echo "<p><strong>Management:</strong> " . $row['Management'] . "</p>"; echo "<img src='images/" . $row['img2'] . "' alt='Crop Image'>"; } echo "</div>"; echo "</body>"; echo "</html>"; } else { echo "No results found."; } } ?>