php - Attempting to display message with no results -


what i"m trying understand how display message user when there no results returned database query. of right have query working correctly. in case there count of messages variable 0 i'd display message saying there no personal messages in outbox. includes not showing table.

what have thought doing moving lines set object properties above code below , setting 2 separate build methods. 1 when there's results , 1 when there isn't. in chance there isn't results i'd have build view blank says random message.

for template library using phil sturgeon's template library.

https://github.com/jeffreydavidson/codeigniter-template

i'm seeking better possibilities this. available assist?

$messages = $this->messages->get_many_by('sender_id', $this->session->userdata('user_id'));  //vardump($messages); die();  if (count($messages > 0)) {     $tmpl = array('table_open' => '<table class="table table-bordered table-condensed table-striped table-vertical-center checkboxs js-table-sortable">', 'row_start' => '<tr class="selectable">');      $this->table->set_template($tmpl);      $this->table->set_heading('', 'to', 'subject', 'date', 'actions');      foreach ($messages $message)     {         $this->table->add_row('', $message->receiver_id, $message->subject, date('f d, y', strtotime($message->date_sent)), '<a href="'. site_url() .'wrestling-manager/personal-messages/sent/delete/' . $message->id .'" class="btn-action glyphicons remove_2 btn-danger"><i></i></a>');     } } else {     echo 'test'; }  $this->template     ->title('personal messages sent')->set_layout('control_panel_view')     ->set_partial('sidebar', 'partials/sidebar')     ->set('user_data', $this->user->with('character')->get($this->session->userdata('user_id')))     ->build('sent_view'); 

if (count($messages > 0)) should be: if (count($messages) > 0)

not sure if fix issue(s), start in right direction.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -