I am trying to perform a search for 2 fields, both are in the same table, I want to look for a data captured in the bd either by the name of the team that is what is captured or by the date when it was captured.
For now I can only search for a single field I can not make it look for any of the 2, or search by name or by date, this is what I have.
This is the function by which I send the values to make the selection.
public function Buscar($campo_buscar, $datos_buscar)
{
# code...
$conexion = $this->getConection();
$rows = array();
if ($datos_buscar == '') {
$query = $conexion->prepare("SELECT * from " . $GLOBALS['tabla']);
} else {
$query = $conexion->prepare("SELECT * from " . $GLOBALS['tabla'] . " WHERE " . $campo_buscar . " LIKE :b");
$query->bindValue(':b', '%' . $datos_buscar . '%', PDO::PARAM_STR);
}
if (!$query) {
return "Error al mostrar";
} else {
$query->execute();
while ($result = $query->fetch()) {
$rows[] = $result;
}
return $rows;
}
//$conexion->close();
}
And here I put the data that I want to look for, but in this case they are 2 is not one,
// Buscar
$campo_buscar = NombreEquipobd;
$datos_buscar= $_POST['txtBuscar'];
//Buscar
$campo_buscarfecha = fechadeta;
$datos_buscartxtf = $_POST['txtfecha'];