I have a basic query I was working on with optional search parameters. The query code is:
$query = $db->prepare("SELECT * FROM VolunDB " . $whereClause . " 1 = 1");
$query->execute();
$result = $query->fetch(PDO::FETCH_OBJ);
$table = $result->fname . " " . $result->lname;
and $whereClause equals: WHERE general = General AND fillmore = Fillmore AND
but it is selecting the wrong name from my database. I have 3 test names in my database, two of which have General and Fillmore matching and one with neither. The First entry in the database is the one with neither matching but it is the only one to get pulled. To pull multiple entries do I have to change something with the fetch(PDO::FETCH_OBJ) or is there something else? But the big question is why is the code pulling the only wrong thing in the database when there are others right after it that match the set parameters.