We find necessary and sufficient conditions for the foliation defined by level sets of a function f(x_{1},...,x_{n}) to be totally geodesic in a torsion-free connection and apply them to find the conditions for d-webs of hypersurfaces to be geodesic, and in the case of flat connections, for d-webs (d > n) of hypersurfaces to be hyperplanar webs. These conditions are systems of generalized Euler equations, and for flat connections we give an explicit construction of their solutions.