foreach $_POST['estilo'] as $estilo{ foreach $_POST['grupo'] as $grupo{ $sql= "select * from tabla where estilo=$estilo and grupo=$grupo"; .... } }