title: PHP SQL displaying outside of intended div when new record is displayed
body: <p>I have a site where a user can post an image, along with some other information about said image. I have a sidebar for users to navigate to other parts of that specific side of my site.</p>
  <p>It looks like it is displaying outside the <code>div</code> that I intended and envisioned all posts would be under, and it's worth mentioning that upon each new post, it is appearing farther and farther outside it's original intended place until reaching the <code>body</code>.</p>
  <p>Here's what I mean. The screenshots are zoomed out screenshots of the site.</p>
  <p>Just below is the code to the container which contains all my code for the tabs and posts, above that is just the &quot;Answer Key&quot; title, and the posting modal that the button to the right of it pulls out. Below it is the php that sends all the info the user inputted into the modal to the database. Apologies for the slight messiness.</p>
  <pre><code>        &lt;div id=&quot;container&quot; class=&quot;row&quot;&gt;
          
              &lt;div class=&quot;tab col-sm-3 border border-end-0 border-start-0&quot; id=&quot;sidenav&quot;&gt;
                  &lt;ul style=&quot;list-style-type:none;padding:0;margin:0;&quot; class=&quot;text-end&quot; id=&quot;menu&quot;&gt;
                      &lt;li&gt;
                          &lt;a class=&quot;tablinks&quot;&gt;Home&lt;/a&gt;
                      &lt;/li&gt;
                      &lt;li&gt;
                          &lt;a class=&quot;tablinks&quot;&gt;Calculators&lt;/a&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/div&gt;
              
              &lt;div id=&quot;entirepost&quot; class=&quot;col-sm-9&quot;&gt;
                  &lt;?php   
                      $query = mysqli_query($conn,&quot;SELECT *,UNIX_TIMESTAMP() - sub_date_created AS TimeSpent from submission LEFT JOIN user on user.user_id = submission.sub_user_id order by submission_id DESC&quot;)or die(mysqli_error());
                      while($submission_row=mysqli_fetch_array($query)){
                          $id = $submission_row['submission_id']; 
                          $upid = $submission_row['sub_user_id']; 
                          $posted_by = $submission_row['firstname'].&quot; &quot;.$submission_row['lastname'];
                  ?&gt;
                  &lt;div id=&quot;posts&quot;&gt;
                  
                      &lt;?php
                          if((isset($_SESSION['role']) &amp;&amp; $_SESSION['role'] == &quot;admin&quot;)){
                              echo &quot;&lt;a style='float:right; font-size: large;' class='btn btn-outline-danger' href='deletesubmission.php?id=&quot; . $id . &quot;'&gt;&lt;b&gt;&amp;times;&lt;/b&gt;&lt;/a&gt;&quot;;
                          }
                          elseif((isset($_SESSION['role']) &amp;&amp; $_SESSION['role'] == &quot;developer&quot;)){
                              echo &quot;&lt;a style='float:right; font-size: large;' class='btn btn-outline-danger' href='deletesubmission.php?id=&quot; . $id . &quot;'&gt;&lt;b&gt;&amp;times;&lt;/b&gt;&lt;/a&gt;&quot;;
                          }
                          elseif((isset($_SESSION['user_id']) &amp;&amp; $_SESSION['user_id'] == $upid)) {
                              echo &quot;&lt;a style='float:right; font-size: large;' class='btn btn-outline-danger' href='deletesubmission.php?id=&quot; . $id . &quot;'&gt;&lt;b&gt;&amp;times;&lt;/b&gt;&lt;/a&gt;&quot;;
                          }
                          else {
                              echo &quot;&quot;;
                          }
                      ?&gt;
                      
                      &lt;h3&gt;&lt;?php echo $submission_row['sub_title']; ?&gt;&lt;/h3&gt;
                      &lt;h5&gt;
                          &lt;?php echo &quot;&lt;span class='badge rounded-pill' id='grade&quot; . $submission_row['grade'] . &quot;Flare'&gt;&quot; . $submission_row['grade'] . &quot; Grade&lt;/span&gt;&quot;; ?&gt; 
                          &lt;?php echo $submission_row['teacher']; ?&gt; · &lt;?php echo $submission_row['subject']; ?&gt;&lt;br&gt;
                      &lt;/h5&gt;
                      &lt;img id=&quot;uploadedImage&quot; src=&quot;&lt;?php echo &quot;images//&quot; . $submission_row['image_url'] ?&gt;&quot;/&gt;
                      &lt;p&gt;
                          &lt;?php echo $submission_row['sub_content'];?&gt;
                          &lt;!-- &lt;/?php echo &quot;images//&quot; . $submission_row['image_url'] ?&gt;&lt;br&gt; --&gt;
                          &lt;table id=&quot;submissionInfoTable&quot;&gt;
                              &lt;thead&gt;
                                  &lt;tr&gt;
                                      &lt;th width=&quot;25%&quot;&gt;Assigned&lt;/th&gt;
                                      &lt;th&gt;Due&lt;/th&gt;
                                  &lt;/tr&gt;
                              &lt;/thead&gt;
                              &lt;tbody&gt;
                                  &lt;tr&gt;
                                      &lt;td&gt;&lt;i&gt;&lt;?php echo date('F d, Y', $submission_row['assigned']) ?&gt;&lt;/i&gt;&lt;/td&gt;
                                      &lt;td&gt;&lt;i&gt;&lt;?php echo date('F d, Y', $submission_row['due']) ?&gt;&lt;/i&gt;&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/tbody&gt;
                              &lt;tbody&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan=&quot;2&quot;&gt;
                                          &lt;?php echo &quot;&lt;b&gt;&quot; . $submission_row['weight'] . &quot;%&lt;/b&gt; of your grade&quot;; ?&gt; 
                                          &lt;i style=&quot;color:grey&quot; class=&quot;bi bi-info-circle&quot; data-bs-toggle=&quot;tooltip&quot; title=&quot;Assignments may weigh differently depending on the teacher's grading system and how many other assignments are under this weight&quot;&gt;&lt;/i&gt;
                                      &lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/tbody&gt;
                          &lt;/table&gt;
                      &lt;/p&gt;
  
                      &lt;small&gt; 
                      &lt;i&gt; 
                          &lt;?php echo $posted_by; ?&gt;
                      &lt;/i&gt;
                      &lt;?php
                          if((isset($_SESSION['role']) &amp;&amp; $_SESSION['role'] == &quot;admin&quot;)){
                              echo &quot;&lt;span class='badge bg-primary'&gt;Admin&lt;/span&gt;&quot;;
                          }
                          elseif((isset($_SESSION['role']) &amp;&amp; $_SESSION['role'] == &quot;developer&quot;)){
                              echo &quot;&lt;span class='badge bg-primary'&gt;Dev&lt;/span&gt;&quot;;
                          }
                          else {
                              echo &quot;&quot;;
                          }
                      ?&gt; ·
                          &lt;?php               
                                  $days = floor($submission_row['TimeSpent'] / (60 * 60 * 24));
                                  $remainder = $submission_row['TimeSpent'] % (60 * 60 * 24);
                                  $hours = floor($remainder / (60 * 60));
                                  $remainder = $remainder % (60 * 60);
                                  $minutes = floor($remainder / 60);
                                  $seconds = $remainder % 60;
                                  if($days &gt; 0)
                                      echo date('F d, Y - H:i:sa', $submission_row['date_created']);
                                  elseif($days == 0 &amp;&amp; $hours == 0 &amp;&amp; $minutes == 0)
                                      echo &quot;A few seconds ago&quot;;       
                                  elseif($days == 0 &amp;&amp; $hours == 0)
                                      echo $minutes.' minutes ago';
                                  elseif($days == 0 &amp;&amp; $hours == 1)
                                      echo $hours.' hour ago';
                                  elseif($days == 0 &amp;&amp; $hours &gt; 1)
                                      echo $hours.' hours ago';
                          ?&gt;
                      &lt;/small&gt;
                      &lt;hr&gt;
                  &lt;/div&gt;
                  &lt;br&gt;
              &lt;/div&gt;
              &lt;?php
              }
              ?&gt;
              &amp;nbsp;
          &lt;/div&gt;
  </code></pre>
  <pre><code>#content {
      margin: 20px;
  }
  
  #postcontent {
      resize: none;
      outline: none;
      border: 1px solid rgb(192, 192, 192);
      transition: all 0.5s ease;
      border-radius: 16px;
      padding: 10px;
      width: 100%;
      margin-top: 15px;
  }
  
  #postcontent:focus {
      border: 1px solid #5865F2;
  }
  
  #entirepost {
      border-right: 1px solid gray;
      border-left: 1px solid gray;
      /* border-radius: 5px; */
      padding: 20px;
      /* width:auto; */
  }
  
  #commentstextarea {
      resize: none;
      outline: none;
      border: 1px solid gray;
      transition: all 0.5s ease;
  }
  
  #commentstextarea:focus {
      border: 1px solid #5865F2;
  }
  
  #comments {
      margin-top: 10px;
  }
  
  #commentcontent {
      margin-top: 1%;
      padding-left:10px;
      border-left: 3px solid #ccc;
      width: 50%;
  }
  
  #commentstitle {
      margin-left: 1%;
      margin-top: 2%;
  }
  
  #title {
      width: 100%;
      font-size: 16px;
      padding: 12px 20px 12px 40px;
      margin-bottom: 12px;
      outline: none;
      border-radius: 16px;
      background-color: transparent;
      border: 1px solid rgb(192, 192, 192);
      color: black;
      transition: all 0.5s ease;
  }
  
  #title:focus {
      border: 1px solid #5865F2;
  }
  
  #header {
      padding:5px;
  }
  
  #NewSubmission {
      background-color: transparent;
      color: #3d4cf3;
      border: 1px solid #a3a9f5;
  }
  
  #NewSubmission:hover {
      background-color:#a3a9f5;
  }
  
  #PageTitle {
      width:40%;
      display: inline;
  }
  
  #container {
      width: 100%;
      padding-right: 0;
  }
  
  #sidenav {
      padding-right: 0;
  }
  
  .tab {
      float: left;
      background-color: #f1f1f1;
      transition: all 0.3s ease;
      height: 100%;
  }
  
  .tab button, .tab a {
      display: block;
      text-decoration: none;
      background-color: inherit;
      color: black;
      padding: 22px 16px;
      width: 100%;
      border: none;
      outline: none;
      text-align: left;
      cursor: pointer;
      transition: 0.3s;
      font-size: 17px;
      transition: all 0.3s ease;
  }
  
  .tab button:hover, .tab a:hover {
      background-color: #ddd;
      transition: all 0.3s ease;
  }
  
  .tab button.active, .tab a:hover {
      background-color: #ccc;
      transition: all 0.3s ease;
  }
  
  #search {
      transition: all 0.3s ease;
      width: 100%;
      padding: 1%;
      margin: 1%px;
      outline: none;
      border: none;
      background-color: rgb(231, 230, 230);
  }
  
  .select2, input {
      margin-top: 10px;
  }
  
  .select2 {
      font-size: 16px;
      outline: none;
      border-radius: 16px;
  }
  
  .select2-selection {
      -webkit-box-shadow: 0;
      box-shadow: 0;
      background-color: #fff;
      border: 0;
      border-radius: 16px;
      color: #555555;
      font-size: 14px;
      outline: 0;
      min-height: 48px;
      text-align: left;
  }
    
  .select2-selection__rendered {
      margin: 10px;
      border-radius: 16px;
  }
  
  .select2-selection__arrow {
      margin: 10px;
      border-radius: 16px;
  }
  
  [class^='select2'] {
      border-radius: 16px !important;
  }
  
  #weight, #DateAssign, #DateDue {
      width: 80%;
      font-size: 16px;
      padding: 8px;
      outline: none;
      border-radius: 16px;
      background-color: transparent;
      border: 1px solid rgb(192, 192, 192);
      color: black;
      transition: all 0.5s ease;
  }
  
  #weight:focus {
      border: 1px solid #5865F2;
  }
  
  .modal-dialog {
      width: 50%;
  }
  
  /* #sidenav {
      width: 17%;
      background-color: #ccc;
  }
  
  #container {
      width: 300px;
      background-color: #ffcc33;
      margin: auto;
  }
  
  #sidenav {
      width: 17%;
      background-color: #ccc;
      float: left;
      height: auto;
  }
  #entirepost {
      width: 83%;
      float: left;
      height: auto;
  }
  #clear {
      clear: both;
  } */
  
  input[type=file]::file-selector-button {
      border: 1px solid #34495e;
      padding: 6px;
      border-radius: 16px;
      background-color: transparent;
      width: 150px;
      transition: all 0.5s ease;
  }
    
  input[type=file]::file-selector-button:hover {
      background-color: #34495e;
  }
  
  #uploadedImage {
      border-radius: 12px;
      max-width: 100%;
      height: auto;
      margin-bottom: 15px;
  }
  
  #submissionInfoTable {
      width: 50%;
  }
  
  #submissionInfoTable th, td {
      padding: 2px;
      /* border: 1px solid black; */
  }
  
  #dropdownmenu i {
      float:right;
  }
  
  #dropdownmenu {
      width: 200px;
  }
  
  
  #grade9thFlare {
      background-color: rgb(133, 244, 228);
      color: rgb(50, 110, 121);
  }
  
  #grade10thFlare {
      background-color: rgb(198, 244, 179);
      color: rgb(50, 100, 54);
  }
  
  #grade11thFlare {
      background-color: rgb(206, 213, 255);
      color: rgb(50, 100, 145);
  }
  
  #grade12thFlare {
      background-color: rgb(239, 222, 240);
      color: rgb(148, 91, 206);
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/omRnE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/omRnE.png" alt="Zoomed out screenshot of my issue" /></a>
  <a href="https://i.stack.imgur.com/l7a80.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l7a80.png" alt="enter image description here" /></a></p>
  <p>The two posts below the first are both underneath the sidebar and are not within the left and right borders of the first post. And, of course, the 2 posts at the bottom were not in there in the original code as shown above. the sidebar is using the bootstrap utility <code>.col-sm-4</code> while the posts are all supposed to be using <code>.col-sm-8</code>.</p>
  <p>This also seems to happen when I attempt to add a comments feature to another part of my site, the discussion board.</p>
  <p>Maybe my googling- I mean, programming skills aren't as good as they usually are, but a good amount of research has yielded no results for my specific issue.</p>