What do I mean by "sections"? Imagine a piece of graph paper. Each square bounded by integer horizontal and vertical grid lines is a "section", and is named after its lower left coordinate — (1,1), (1,2), etc.
Given two arbitrary points, that do not have to be integers, I need to find all of the 'sections' that the line segment made by connecting those two points travels through.
Let's call your two points
$$\begin{align} A &= (x_a, y_a) \\ B &= (x_b, y_b) \end{align}$$
Then, the segment joining them is the set of all points $S(t)$ where
$$S(t) = ((1-t) x_a + t x_b,\quad (1-t) y_a + t y_b)$$
for all $0 \le t \le 1$.
From there, to enumerate the "sections", you can either enumerate all the integer $x$ values or the integer $y$ values. The problem is symmetrical, but iterating over $x$ will probably feel more natural.
So, enumerate all integers $x_i$ between $x_a$ and $x_b$.
$$t_i = \frac{x_i - x_a}{x_b - x_a}$$
Since you want the lower-left corner, you want to take the floor of the $y$-coordinate.
$$S_i = \left(x_i, \left\lfloor (1-t_i)y_a + t_i y_b\right\rfloor\right)$$
Of course, if you have a vertical line where $x_a = x_b$, then you have to treat that as a trivial special case — just enumerate all the $(\left\lfloor x_a \right\rfloor, y_i)$ for all integer $y_i$ between $y_a$ and $y_b$.