30.include.cache.php 926 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. $con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
  3. // Check connection
  4. if (mysqli_connect_errno())
  5. {
  6. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  7. }
  8. $result = mysqli_query($con, "SELECT * FROM `plant_specifications`");
  9. // mysqli_query returns false if something went wrong with the query
  10. if ($result === FALSE)
  11. {
  12. die(mysqli_error($con)); // TODO: better error handling
  13. }
  14. else
  15. {
  16. ?>
  17. <div class="col-md-4 form-group">
  18. <small id="lab_no" class="form-text text-muted">Crop Type <span class="error">*</span></small>
  19. <div><select class="form-control form-control-sm" name="crop_type" id="crop_type" required>
  20. <option>Select the type of Crop...</option>
  21. <?php
  22. while ($row = mysqli_fetch_array($result))
  23. {
  24. echo "<option id=" . $row['id'] . ">" . $row['plant_type'] . "</option>";
  25. }
  26. ?>
  27. </select></div>
  28. </div>
  29. <?php
  30. }
  31. mysqli_close($con);
  32. return;