Ts91 0 Newbie Poster

Hi Guys!

im making a small website based around a very simple and basic mvc pattern (in this case just seperating files into different folders)
Im currently stuck on selecting data from the database and displaying it.

My model looks like this:

<?php
require_once('../Controller/config.php');

class Readings 
{
    public $dbconn;

    public function __construct()
    {
        $database = new Database();
        $db = $database->dbConnection();
        $this->dbconn = $db;
    }

public function getElecReadings(){
        try {
            $stmt = $this->dbconn->prepare("SELECT ElecUsage, DateAdded FROM elec_readings WHERE AccountNumber = '. $_SESSION['user_session'] .' ");
            $stmt->execute();
            return $stmt;
        } catch (Exception $e) {

        }
    }
}

?>

Although im not sure if my select statement is correct where it retrieves data based on the account number of the user logged in.
I want the selected data to be displayed in a table

My view looks like this:

<div class="elecUsage"> <form id="elecRead" method="POST"> <h2>Electricity Usage</h2>

                Please enter your latest electricity meter reading:
                <br> <input type="text" name="txtElecUsage" required/> <br> <input type="submit" name="btn-submitElecUsage" value="Submit"/> </form> <br>
            Previous Electricity meter readings:
            // THIS IS WHERE THE SELECTED DATA SHOULD BE DISPLAYED.
        </div>

Im just a little confused as to what would go into my controller?
Also if there is an easier/cleaner way to do it with Javascript/Ajax.
Any help would be appreciated.
Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.