title: Php Private Message reply only functioning on the last row?
body: <p>I am wondering why the code only works on the last row of the message reply, I can't reply on the latest message but I can reply on the last message, the messages are descending.</p>
  
  <p>Please take a look at messages.php:</p>
  
  <pre><code>&lt;form action="read_message.php" method="post"&gt;
  &lt;div class="pull-right"&gt;
      &lt;button class="btn btn-info"  name="read"&gt;&lt;i class="icon-check"&gt;&lt;/i&gt; Read&lt;/button&gt;
  
      Check All &lt;input type="checkbox"  name="selectAll" id="checkAll" /&gt;
      &lt;script&gt;
          $("#checkAll").click(function () {
              $('input:checkbox').not(this).prop('checked', this.checked);
          });
      &lt;/script&gt;                   
  
  &lt;/div&gt;
  
  &lt;ul class="nav nav-pills"&gt;
      &lt;li class="active"&gt;&lt;a  href="messages.php"&gt;&lt;i class="icon-envelope-alt"&gt;&lt;/i&gt;inbox&lt;/a&gt;&lt;/li&gt;
      &lt;li class=""&gt;&lt;a  href="sent_message_user.php"&gt;&lt;i class="icon-envelope-alt"&gt;&lt;/i&gt;Send  messages&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;?php
  $query_announcement = mysql_query("select * from message_received
                                                              LEFT JOIN user ON user.user_id = message_received.user_id
                                                              where  message_received.receiver_id = '$session_id' order by date_sent DESC
                                                              ")or die(mysql_error());
  $count_my_message = mysql_num_rows($query_announcement);
  if ($count_my_message != '0') {
      while ($row = mysql_fetch_array($query_announcement)) {
          $id = $row['message_id'];
          $id_2 = $row['message_id'];
          $fn = $row['firstname'];
          $ln = $row['lastname'];
          $status = $row['message_status'];
          $sender = $row['user_id'];
          $sender_name = $fn . ' ' . $ln;
  
          $receiver = $row['receiver_id'];
          ?&gt;&lt;div class="alert alert-info"&gt;
              &lt;div class="post"  id="del&lt;?php echo $id; ?&gt;"&gt;
                  &lt;div class="message_content"&gt;
                      &lt;?php echo $row['content']; ?&gt;
                  &lt;/div&gt;
                  &lt;div class="pull-right"&gt;
                      &lt;?php if ($status == 'read') {
  
                      } else {
                          ?&gt;
                          &lt;input id="" class=""  name="selector[]" type="checkbox" value="&lt;?php echo $id; ?&gt;"&gt;
      &lt;?php } ?&gt;
                  &lt;/div&gt;
                  &lt;hr&gt;
                  Send by: &lt;strong&gt;&lt;?php echo $fn . ' ' . $ln; ?&gt;&lt;/strong&gt;
                  &lt;i class="icon-calendar"&gt;&lt;/i&gt; &lt;? php echo $row['date_sent']; ?&gt;
                  &lt;div class="pull- right"&gt;
                      &lt;a class="btn  btn-link"  href="#reply&lt;?php echo $id; ?&gt;" data-toggle="modal" &gt;&lt;i  class="icon-reply"&gt;&lt;/i&gt; Reply &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="pull-right"&gt;
                      &lt;a class="btn btn-link"   href="#&lt;?php echo $id; ?&gt;" data-toggle="modal" &gt;&lt;i class="icon-remove"&gt;&lt;/i&gt;  Remove &lt;/a&gt;
                      &lt;?php include("remove_inbox_message_modal.php"); ?&gt;
      &lt;?php include("reply_inbox_message_modal_user.php"); ?&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
      &lt;?php }
   } else { ?&gt;
      &lt;div class="alert alert-info"&gt;&lt;i class="icon- info-sign"&gt;&lt;/i&gt; No   Message Inbox&lt;/div&gt;
  &lt;?php } ?&gt;      
  &lt;/form&gt; 
  </code></pre>
  
  <p>NOW THIS is the function for read_message.php, I can't see any error, please help me.</p>
  
  <pre><code>&lt;?php
  
  if (isset($_POST['reply'])) {
  $sender = $_POST['sender'];
  $receiver = $_POST['receiver'];
  
  $my_message = $_POST['my_message'];
  
  
  mysql_query("insert into message_received    (user_id,receiver_id,content,date_sent)  values('$receiver','$sender','$my_message',NOW())")or die(mysql_error());
  mysql_query("insert into message_sent   (receiver_id,content,date_sent,user_id)   values('$sender','$my_message',NOW(),'$receiver')")or die(mysql_error());
  echo "&lt;script&gt; alert('Your message has been sent $my_message')    &lt;/script&gt;";
  echo "   &lt;script&gt;location.replace('messages.php')&lt;/script&gt;";
  ?&gt;
  &lt;script&gt;
      alert('Message Sent');
      window.location = "messages.php";
  &lt;/script&gt;
  &lt;?php
  
  }
  ?&gt;
  </code></pre>
  
  <p>now this is the reply modal codes,</p>
  
  <pre><code> &lt;!-- Modal --&gt;
   &lt;div id="reply&lt;?php echo $id; ?&gt;" class="modal hide fade" tabindex="-1"     role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"&gt;
   &lt;div class="modal-header"&gt;
   &lt;button type="button" class="close" data-dismiss="modal" aria- hidden="true"&gt;x&lt;/button&gt;
  &lt;h3 id="myModalLabel"&gt;Reply&lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="modal-body"&gt;
  &lt;center&gt;
  
  &lt;div class="control-group"&gt;
      &lt;label class="control-label" for="inputEmail"&gt;To:&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;input type="hidden" name="sender" id="inputEmail" value="&lt;?php echo $sender; ?&gt;" readonly&gt;
          &lt;input type="hidden" name="receiver" id="inputEmail" value="&lt;?php echo $receiver; ?&gt;" readonly&gt;
          &lt;input type="hidden" name="uid" id="inputEmail" value="&lt;?php echo $uid; ?&gt;" readonly&gt;
          &lt;input type="hidden" name="my_name" value="&lt;?php echo $reciever_name; ?&gt;" readonly&gt;
          &lt;input type="text" name="name_of_sender"  id="inputEmail" value="&lt;?php echo $sender_name; ?&gt;" readonly&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="control-group"&gt;
      &lt;label class="control-label" for="inputPassword"&gt;Content:&lt;/label&gt;
      &lt;div class="controls"&gt;
          &lt;textarea name='my_message'&gt;&lt;/textarea&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="control-group"&gt;
      &lt;div class="controls"&gt;
      &lt;button type="submit" name="reply" id="&lt;?php echo $id; ?&gt;" class="btn btn-success reply"&gt;&lt;i class="icon-reply"&gt;&lt;/i&gt; Reply&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
   &lt;/center&gt;
   &lt;/div&gt;
   &lt;div class="modal-footer"&gt;
   &lt;button class="btn" data-dismiss="modal" aria-hidden="true"&gt;&lt;i class="icon-remove icon-large"&gt;&lt;/i&gt; Close&lt;/button&gt;
   &lt;button   id="&lt;?php echo $id; ?&gt;" class="btn btn-danger remove" data- dismiss="modal" aria-hidden="true"&gt;&lt;i class="icon-check icon-large"&gt;&lt;/i&gt;   Yes  &lt;/button&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>when I reply to a message the message is sent but it has no content but   data from sender, date and time is saved in the database, but in the lowest row, it all functions well? please help me. thank you</p>