0byt3m1n1
Path:
C:
/
wamp64
/
www
/
Crops
/
[
Home
]
File: complete.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, Scientific_Name, Family, img, Nutrient, Symptoms, Management, img2, Dicease, d_symptom, D_mng, img3, Pests, Psymptom, p_mng, img4 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: 900px;"; echo " margin: 0 auto;"; // Add this line to center the container horizontally echo " background-color: #fff;"; echo " padding: 20px;"; echo " border-radius: 8px;"; echo " text-align: center"; echo "}"; echo "h2 {"; echo " font-size: 24px;"; echo " margin-bottom: 10px;"; echo "}"; echo "p {"; echo "font-size: 16px;"; echo "margin-bottom: 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 "<p><strong>Name:</strong> " . $row['Name'] . "</p>"; echo "<p><strong>Scientific Name:</strong> " . $row['Scientific_Name'] . "</p>"; echo "<p><strong>Family:</strong> " . $row['Family'] . "</p>"; echo "<p><strong>Image:</strong></p>"; echo "<img src='images/" . $row['img'] . "' alt='Crop Image'>"; 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 "<h2>Details of Disease</h2>"; echo "<p><strong>Disease:</strong> " . $row['Dicease'] . "</p>"; echo "<p><strong>Symptoms:</strong> " . $row['d_symptom'] . "</p>"; echo "<p><strong>Management:</strong> " . $row['D_mng'] . "</p>"; echo "<p><strong>Image:</strong></p>"; echo "<img src='images/" . $row['img3'] . "' alt='Crop Image'>"; echo "<h2>Details of Pests</h2>"; echo "<p><strong>PESTS:</strong> " . $row['Pests'] . "</p>"; echo "<p><strong>Symptoms:</strong> " . $row['Psymptom'] . "</p>"; echo "<p><strong>Management:</strong> " . $row['p_mng'] . "</p>"; echo "<p><strong>Image:</strong></p>"; echo "<img src='images/" . $row['img4'] . "' alt='Crop Image'>"; } echo "</div>"; echo "</body>"; echo "</html>"; } else { echo "No results found."; } } ?>