How to update message status read in mysql using onclick event simply by clicking a link

I have a PHP chat system with a notification option (where users can see how and who sent them messages). Now I want if a user/receiver click on a user profile (in chat page) on the sidebar and there is a sort of messages unread, after clicking messages status must be changed to read (by the default message status=‘0’, and have to change to status=1’).

                       <a href="inbox?msgid=<?php echo $id;?>" type="button" onclick="msgRead()" style="width:100%">
                           <div class="row con_cont_list">
                               <div class="col-3">
                                   <img src="media/<?php echo $ProfileImg;?>" width="60px" height="60px" alt="">
                               <div class="col-9">
                                   <p><?php echo $FullName;?>
                                     <?php if($frnd_msgs_noti):?>
                                    <span class="badge badge-danger" style="border-radius:50%;"><?php echo $frnd_msgs_noti;?></span>
                                    <?php endif;?>

Inside your PHP code for the inbox, you’re retreiving the message via msgid when the person clicks on that link.

When you retrieve the message, send a second query to update it.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.