php - laarvel query builder output is messy -


i'm new laravel framework , faced problem , when send query results in form :

[{"visitors":3}] 

here code used result :

<?php echo $q = db::table('visitors')->select('visitors')->get(); ?> 

is there missed ?

this not best practice

<?php echo $q = db::table('visitors')->select('visitors')->get(); ?> 

following mvc pattern, should query in controller,

$q = db::table('visitors')->select('visitors')->get(); 

then pass $q in view. loop through $q results. if need specific result, $id = 3, use where.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -