html - my <ul> dissapears when generating <li> in PHP? -
i'm having weird error ul tag dissapears when generate li tags in it, have no idea if here me great.
the html gets generated in:
<div class="col-md-12 col-xs-12"> <div id="tickets"> <ul>'.$ticket->generatetickets().'</ul> </div> </div>
my php function
public function generatetickets(){ $cols = array ('id','description','ticket_id'); $items = $this->db->orderby('id')->get("tickets", null, $cols); if ($this->db->count > 0){ foreach ($items $item) { echo '<li><a href="?p=support&action=readticket&tid='.$item['id'].'">ticket #'.$item['ticket_id'].'<br/></a> <p>'.substr($item['description'],0,20).'..</p> </li>'; } } }
console showing ul dissapeared: http://piclair.com/r45q7
in generatetickets function, you're echoing immediately. since concatenation in html file done after function done, output first. should either return values ( replace echo
return
, move out of loop ) or in html, dont concatenate strings.
$result = ''; foreach ( $items $item ) { $result .= '<li ...'; } return $result;
Comments
Post a Comment