I have the following code to combine the two columns data and display distinct values in the dropdown list:
<?php
include_once "connect.php";
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$stmt = $conn->query("SELECT DISTINCT A, B FROM Contracts WHERE something='Ssomething' as amount");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo "<option value='" . $row['amount'] . " " . $row['amount'] . "</option>";
}
$conn->db=null;
?>
I get the error:
Fatal error: Call to a member function fetch() on a non-object in xyz line 5.
Any help is appreciated. Thank you in advance.