0

Sorry for posting simple issue which I failed to find out:

public function show(){

function display(){

    $q = DB::table('posts')->get();

    return $q;
  }
    $m      = new Post;
    $data  = $m->display();
    foreach($data as $row)
    {
        ?>
            <tr>
                <td><?= $row->id ?></td>
                <td><?= $row->name ?></td>
                <td><?= $row->description ?></td>
            </tr>
        <?

    }
    exit();
}

mainly the problem I am facing with the foreach loop in controller wich I am trying to display with ajax request in view.

Wasid Hossain
  • 55
  • 1
  • 11

1 Answers1

1
public function show() {

        function display() {

            $q = DB::table('posts')->get();

            return $q;
        }

        $m = new Post;
        $data = $m->display();
        foreach ($data as $row) {
            ?>
            <tr>
                <td><?= $row->id ?></td>
                <td><?= $row->name ?></td>
                <td><?= $row->description ?></td>
            </tr>
            <?php
        }
        exit();
    }
PHP Geek
  • 3,949
  • 1
  • 16
  • 32