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 3721744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:39:44+00:00 2026-05-19T05:39:44+00:00

I have a column in my database’s messages table. It is called status and

  • 0

I have a column in my database’s messages table. It is called “status” and is basically updated each time a user has “read” a message, makes a message “favourite”. By default the columns tinyint value is set to “0”.

0 = unread
1 = read
2 = favourite

I have some jquery and css going on in my inbox page which enables a user to be able to select all message checkboxes or none if they have been selected.

Right above my inbox messages are these links “all – none – read – unread – favourite…” Which are basically options for what messages a user can have automatically checked/selected.

What I want to do

I would like to have my jquery grab the values from my databases messages table.. status column and some how uses those to determine if a message has been read.. is unread or has been made a favourite.

With PHP I have done something similar already with a simple if statement.

  <?php foreach ($query as $row):  ?>
  <tr>
    <td width="5%"><input name="message" id="messages" type="checkbox" value=""></td>
    <td width="5%">fav*</td>
    <td><?php if ($row['status'] == 0) { echo "Unread"; } elseif ($row['status'] == 1) {echo "Read";} elseif ($row['status'] == 3) { echo "Replied";}?></td>
    <td><?php echo $row['from_user']; ?></td>
    <td><?php echo $row['subject'] . " - " . $row['message']; ?></td>
    <td><?php if ($row['date_sent'] == date('Y-m-d')) { echo $row['time_sent']; } else echo $row['date_sent']; ?></td>
  </tr>
  <?php endforeach; ?>

JQuery

 <script type="text/javascript">

$('#links').delegate('a', 'click', function(ev) {
    // reset all checkboxes
    $('input:checkbox').attr('checked', false);

    // get info, what is the user choice
    whichMessages = $(this).attr('id');

    // do our main work - select checkboxes
    switch (whichMessages) {
    case 'all':
        $('input:checkbox').attr('checked', true);
        break;
    case 'read':
        $('input:checkbox.read').attr('checked', true);
        break;
    case 'unread':
        $('input:checkbox.unread').attr('checked', true);
        break;
    case 'fav':
        $('input:checkbox.fav').attr('checked', true);
        break;
    };

    // add some user-frendly markup
    $('#links a').removeClass('active');
    $(this).addClass('active');

    // and standard action to prevent standard link click event
    ev.preventDefault();
});



</script>

HTML

<p id="links">
    <a href="#" id="all" class="pseudo">all</a>,
    <a href="#" id="none" class="pseudo active">none</a>,
    <a href="#" id="read" class="pseudo">read</a>,    
    <a href="#" id="unread" class="pseudo">unread</a>,
    <a href="#" id="fav" class="pseudo">favourite</a>
  • 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-19T05:39:45+00:00Added an answer on May 19, 2026 at 5:39 am

    Copy the if statement, or better yet use the switch statement to print the correct css class in the checkbox

    <?php foreach ($query as $row):  ?>
      <tr>
     <?php switch($row['status']){
      case 0: $status = "Unread"; break;
      case 1: $status = "Read"; break;
      case 3: $status = "Replied"; break;
      default: $status = '';
     }?>   
     <td width="5%"><input name="message" id="messages" type="checkbox" value="" class=<?php echo $status;?>"></td>
        <td width="5%">fav*</td>
        <td><?php echo $status;?></td>
        <td><?php echo $row['from_user']; ?></td>
        <td><?php echo $row['subject'] . " - " . $row['message']; ?></td>
        <td><?php if ($row['date_sent'] == date('Y-m-d')) { echo $row['time_sent']; } else echo $row['date_sent']; ?></td>
      </tr>
    <?php endforeach; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a column in my database table which has lows of text and
In mysql database i have this column called: Name: Date Type: datetime I have
I have a string column in a database table which maps to an Enum
I have a column in my database that will be updated randomly. Whenever that
suppose i have one column in mysql database which is stated last time one
I have premiere_poland column in database table which is date type. /** @Column(type=date, nullable=TRUE)
I have a column in my database called 'category' that contains the name of
Hello i have a database column called price and the data in it is
I have a column in my database called dob of type datetime. How do
In sql server database, I have column name Image which has urls like http://www.xyz.com/1009/image1.jpg

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.