Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7633159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:48:22+00:00 2026-05-31T06:48:22+00:00

This code works when I have data rows returned for the messages object but

  • 0

This code works when I have data rows returned for the messages object but when there isn’t I have it returning NULL in which case I am having a hard time getting this code to still show up correctly so that it works with the tabs plugin I have up. I’m using datatables for my tables.

Anybody have any ideas?

<!-- Start of the main content -->
<div id="main_content">

<h2 class="grid_12">Personal Messages</h2>
<div class="clean"></div>

<div class="grid_8">

    <div id="tab-panel-1" class="box">

        <div class="header">
            <img src="<?php echo base_url() ?>assets/img/icons/packs/fugue/16x16/shadeless/mail.png" width="16" height="16" />
            <h3>Messages</h3><span></span>
            <ul>
                <li><a href="#tab-1">Inbox Messages</a></li>
                <li><a href="#tab-2">Sent Messages</a></li>
                <li><a href="#tab-3">Compose Message</a></li>
            </ul>
        </div>
        <div class="content">
            <div id="tab-1" class="tab-content">
                <table id="inbox" class="table dataTable">
                    <thead>
                        <tr>
                            <th></th>
                            <th>Date</th>
                            <th>Subject</th>
                            <th>From</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        if ($messages[0] !== NULL)
                        {
                            foreach ($messages[0] AS $message)
                            {
                                echo '<tr>';
                                    echo '<td style="text-align: center">';
                                    if ($message->message_read == 1)
                                    {
                                        echo '<img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail-open.png />';
                                    }
                                    else
                                    {
                                        echo '<img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail.png />';
                                    }
                                    echo '</td>';
                                    echo '<td>'.date('F d, Y', strtotime($message->date_sent)).'</td>';
                                    echo '<td>'.$message->subject.'</td>';
                                    echo '<td>'.$message->first_name.' '.$message->last_name.'</td>';
                                    echo '<td></td>';
                                echo '</tr>';
                            }
                        }
                        else
                        {
                            echo '<tr>';
                            echo 'No records';
                            echo '</tr>';
                        }
                        ?> 
                    </tbody>
                </table>
            </div>

            <div id="tab-2" class="tab-content">
                <table id="sent" class="table dataTable">
                    <thead>
                        <tr>
                            <th></th>
                            <th>Date</th>
                            <th>Subject</th>
                            <th>To</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        if ($messages[1] !== NULL)
                        {
                            foreach ($messages[1] AS $message)
                            {
                                echo '<tr>';
                                    echo '<td style="text-align: center">';
                                    if ($message->message_read == 1)
                                    {
                                        echo '<img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail-open.png />';
                                    }
                                    else
                                    {
                                        echo '<img src='.base_url().'assets/img/icons/packs/fugue/16x16/mail.png />';
                                    }
                                    echo '</td>';
                                    echo '<td>'.date('F d, Y', strtotime($message->date_sent)).'</td>';
                                    echo '<td>'.$message->subject.'</td>';
                                    echo '<td>'.$message->first_name.' '.$message->last_name.'</td>';
                                    echo '<td></td>';
                                echo '</tr>';
                            }
                        }
                        else
                        {
                            echo '<tr>';
                            echo 'No records';
                            echo '</tr>';
                        }
                        ?> 
                    </tbody>
                </table>
            </div>

            <div id="tab-3" class="tab-content">
                <?php echo form_open('') ?>
                        <div class="_100">
                            <p>
                                <?php echo form_label('Recipient', 'recipient'); ?>
                                <select name="to" class="required">
                                    <option></option>
                                    <?php
                                    foreach ($users AS $user)
                                    {
                                        echo '<option>'.$user->first_name.' '.$user->last_name.'</option>';
                                    }
                                    ?>
                                </select>
                            </p>
                        </div>
                        <div class="_100">
                            <?php echo form_label('Subject', 'subject'); ?>
                            <?php echo form_input('subject', '', 'class=required'); ?>
                        </div>
                         <div class="_100">
                            <?php echo form_label('Message', 'message'); ?>
                            <?php echo form_textarea('message', '', 'class=required'); ?>
                        </div>
                        <?php echo form_hidden('sender', $this->session->userdata('user_id')); ?>   
                    <div class="actions">
                        <div class="actions-left">
                            <?php echo form_reset('reset', 'Reset'); ?>           
                        </div>
                        <div class="actions-right">
                            <?php echo form_submit(array('id' => 'submit', 'name' => 'submit'), 'Submit Message'); ?>           
                        </div>
                    </div>
                <?php echo form_close(); ?>
            </div>

        </div> <!-- End of .content -->

        <div class="clear"></div>

    </div>

</div>

<div class="clear"></div>

Heres what its doing:
http://jsfiddle.net/MGram/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:48:24+00:00Added an answer on May 31, 2026 at 6:48 am
    echo '<tr>';
    echo 'No records';
    echo '</tr>';
    

    needs td

    echo '<tr><td colspan="5">';
    echo 'No records';
    echo '</td></tr>';
    

    There seems to be an issue with javascript and the instantiation of the tabs plugin. I don’t see the js for the tabs anywhere. But I did see that there is a CI error on the page in a select:

    <select name="to" class="required">
                                            <option></option>
    
                                            <div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
    
    <h4>A PHP Error was encountered</h4>
    
    <p>Severity: Warning</p>
    <p>Message:  Invalid argument supplied for foreach()</p>
    <p>Filename: views/pmsystem.php</p>
    <p>Line Number: 121</p>
    
    </div>                                    </select>
    

    which can sometimes mess up javascript stuff.

    Are you getting anything in the error console?

    Can we see the js?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code, which works fine, but I would like to be able
I have this code which export data from GridView to csv. It works with
I have this code that works in a unit test but doesn't work when
I have this code which compiles and works as expected: class Right {}; class
I have this code in my cfm, which works <cfif not StructIsEmpty(form)> <cfset larray
I have this code to write to a file, it works perfect but I
I have this code which extracts data from a csv file and then reformats
I have the following code: Bear in mind that while this code works on
I have this piece of code that works fine in subsonic 2.2, I migrated
Never thought I'd have this problem :) The following snippet of code works in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.