| 123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php return '$con = mysqli_connect("localhost", "root", "R3M0T31", "cropmonitor");
- // Check connection
- if (mysqli_connect_errno())
- {
- echo "Failed to connect to MySQL: " . mysqli_connect_error();
- }
- $result = mysqli_query($con, "SELECT * FROM `plant_specifications`");
- // mysqli_query returns false if something went wrong with the query
- if ($result === FALSE)
- {
- die(mysqli_error($con)); // TODO: better error handling
- }
- else
- {
- ?>
- <div class="col-md-4 form-group">
- <small id="lab_no" class="form-text text-muted">Crop Type <span class="error">*</span></small>
- <div><select class="form-control form-control-sm" name="crop_type" id="crop_type" required>
- <option>Select the type of Crop...</option>
- <?php
- while ($row = mysqli_fetch_array($result))
- {
- echo "<option id=" . $row[\'id\'] . ">" . $row[\'plant_type\'] . "</option>";
- }
- ?>
- </select></div>
- </div>
- <?php
- }
- mysqli_close($con);
- return;
- ';
|