0byt3m1n1
Path:
C:
/
wamp64
/
www
/
crop
/
Crops
/
[
Home
]
File: index.php
<!DOCTYPE html> <html> <head> <title>Crop and Nutrient Selection</title> <style> body { display: flex; justify-content: center; align-items: center; min-height: 100vh; background-color: #e8f7d2; font-family: Arial, sans-serif; } .container { max-width: 600px; padding: 20px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); } h1 { text-align: center; position: absolute; top: 20px; left: 20%; transform: translateX(-50%); } h2 { text-align: center; margin-top: 0; padding-top: 20px; } form { margin-top: 20px; display: flex; flex-direction: column; align-items: flex-start; } label { display: block; margin-bottom: 5px; font-weight: bold; } select { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; margin-bottom: 10px; } input[type="submit"] { margin-top: 10px; padding: 10px 20px; background-color: #4CAF50; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } hr { margin-top: 30px; border: none; border-top: 1px solid #ccc; } .result { margin-top: 20px; padding: 10px; background-color: #f9f9f9; border: 1px solid #ccc; border-radius: 4px; } </style> </head> <body> <div class="container"> <form action="display.php" method="post"> <label for="crop">Select Crop:</label> <select name="crop" id="crop"> <option value="">Select Crop</option> <!-- Add crop options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch crop names from the database $cropQuery = "SELECT Distinct Name FROM crop"; $cropResult = mysqli_query($conn, $cropQuery); // Display crop options while ($row = mysqli_fetch_assoc($cropResult)) { echo "<option value='" . $row['Name'] . "'>" . $row['Name'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <label for="nutrient">Select Nutrient:</label> <select name="nutrient" id="nutrient"> <option value="">Select Nutrient</option> <!-- Add nutrient options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch nutrient names from the database $nutrientQuery = "SELECT Distinct Nutrient FROM crop"; $nutrientResult = mysqli_query($conn, $nutrientQuery); // Display nutrient options while ($row = mysqli_fetch_assoc($nutrientResult)) { echo "<option value='" . $row['Nutrient'] . "'>" . $row['Nutrient'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <label for="disease">Select Disease:</label> <select name="disease" id="disease"> <option value="">Select Disease</option> <!-- Add disease options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch disease names from the database $diseaseQuery = "SELECT Distinct Dicease FROM crop"; $diseaseResult = mysqli_query($conn, $diseaseQuery); // Display disease options while ($row = mysqli_fetch_assoc($diseaseResult)) { echo "<option value='" . $row['Dicease'] . "'>" . $row['Dicease'] . "</option>"; } // Close the database connection mysqli_close($conn); ?> </select> <label for="Pests">Select Pests:</label> <select name="Pests" id="Pests"> <option value="">Select Pests</option> <!-- Add pests options dynamically from the database --> <?php // Establish a database connection $servername = "localhost"; $username = "root"; $password = ""; $dbname = "crops"; $conn = mysqli_connect($servername, $username, $password, $dbname); // Fetch pests names from the database $pestsQuery = "SELECT DISTINCT TRIM(LOWER(Pests)) AS Pests FROM crop"; $pestsResult = mysqli_query($conn, $pestsQuery); // Display pests options while ($row = mysqli_fetch_assoc($pestsResult)) { echo "<option value='" . $row['Pests'] . "'>" . $row['Pests'] . "</option>"; } ?> </select> <input type="submit" name="submit" value="Submit"> </form> <hr> </body> </html>