This paper considers the linear-quadratic (LQ) optimal control problem for systems governed by a class of second-order parabolic partial differential equations (PDEs). This problem is significant in many areas of mathematics, control, engineering and so on, and thus has received great attention in the past decades. Different from the previous articles where the operator is applied to present the controller, the main contribution of this paper is to propose the discretisation-then-continuousization method, which is explicit and implementable. The solvability condition of the LQ optimal control problems is given based on a set of differential Riccati equations, and an explicit numerical calculation way of these equations and the design of the optimal controller are provided.