php - foreach() return a null value -


I now have another error, when I try to display a result in my view, the result is null and I can not do

at the controller (home.php):

  $ data [ 

'Hasil5'] = $ this- & gt; Home_model-> Popular_list (); Model (home_model.php) function popular_list ():

  function popular_list ($ limit = 2) {$ this- & gt; Db- & gt; Selection ('news *.'); $ This- & gt; Db- & gt; Where ('id', $ this-> uri-> section (3)); $ This- & gt; Db- & gt; Where ('Publish', 1); $ This- & gt; Db- & gt; Where ('see' = ', 5); $ This- & gt; Db- & gt; Order_by ('id', 'desc'); $ This- & gt; Db- & gt; Boundary ($ border); $ Query = $ this- & gt; Db- & gt; Receive ('news'); Return $ query- & gt; result (); } // Thanks to "Communications_V"  

and on my idea (home.php) as a part of "popular news":

  & Lt; H2 & gt; Most popular news: & lt; / H2 & gt; & Lt ;? Php foreach ($$ 5 as $ 5 data):? & Gt; & Lt; Div class = "welcome speed" & lt; Img class = "imgl" src = "& lt ;? php echo base_ url () ;? & gt; property / news / original /  image ;;> alt = "" Height = "119" width = "125" /> 
gt; h2 & gt; & lt; php echo anchor ($ data 5- & gt; ; Category; / Detail /'.$$ Data 5- & gt; ID, $ data 5- & gt; Title)? & Gt; & lt; / h2 & gt; & lt; p & gt; & lt ;? Php echo $ data 5- & gt; sinusis;? & Gt; & lt; / div & gt; & lt; / div & gt; & lt ;? php endforeach;? & Gt;

The result is tap, can you correct it again? Thank you ..

Try this:

  function Dear_list ($ border = 2) {$ query = $ this-> db-> Select ('*') -> where ('id', $ this-> uri- & gt; Segment ($ range) -> Get ('news') (1) -> where ((' id ',' dexc ') -> where (' Seen & gt; = ', 5) - & gt;; print_r ($ query- & gt; result ()); return $ query- & gt; result (); }  

You can insert the entire code in the $ query variable. Even more, you have your $ this-> db-> gt; Where () parameter can be improved by inserting it into the array.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -