This question is more about "good pratices" than a real problem; I just started with php and jquery, but I would know more in details what I'm doing and why.

What I'm trying to get: catch user request (with a form), query database and then show result in a table. All using ajax call and jquery.

Now, I have my controller.php:

```
class Controller {
public $model;
public function __construct() {
    $this->model = new Model ();
}

public function run() {
    $action = isset ( $_REQUEST ["action"] ) ? $_REQUEST ["action"] : $action = "home";

    switch ($action) {
        case "home" :
            //doing stuff
            break;
        case "search" :
            //this function will take arguments then perform a query and return results.
            $result = $this->search();

            //I put $result into a $prod field of my model.
            $this->model->prod = $result;

            //then I would display acquired data into a table.
            echo include 'view/include/result-table.php';
            break;
    }
}

function search() {
    //query DB etc..
}

```

}

And this is my table (view/include/result-table.php), I would like insert this into a div in my page.

```
            <?php
        if (isset ( $this->model->prod )) {
            if (count ( $this->model->prod ) == 0) {
                echo "<h4 class=\"info\"> No product find";
            } else {
                ?>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Name</th>
                    <th>Price</th>
                    <th>Descr</th>
                    <th>Qty</th>
                </tr>
            </thead>
            <tbody>
            <?php
                foreach ( $this->model->prod as $p ) {
                    echo "<tr><td> $p->id </td>";
                    echo "<td>" . ucfirst ( $p->name ) . "</td>";
                    echo "<td>" . ucfirst ( $p->descr ) . "</td>"
                    // and so on..
                }
                ?>
            </tbody>
        </table>

        <?php
            }
        }
        ?>

```

Problem 1: the "echo include "view/include/....php" seems to echoes also a 1 (a digit) at the end of the page (or the div). Why?

"Problem 2": This is working pretty well, but I'm not sure that is the correct way to do this. Are there any other solutions to query a DB and display results in a div, with only jquery/ajax request? (I don't want a page refresh every time). Maybe something that can speed up responses and/or improves security.

Thank you very much!