title: Limiting data Inserts on database row
body: <p>Hello currently I'm working with this line of code:</p>
  
  <pre><code>    if( $get_display-&gt;level== "Nursery"){
          $lbl="Kinder";
          }
      else if( $get_display-&gt;level== "Kinder"){
          $lbl="Preparatory";
          }
      else if( $get_display-&gt;level== "Preparatory"){
          $lbl="Grade 1";
          }
      else if( $get_display-&gt;level== "Grade 1"){
          $lbl="Grade 2";
          }
       ******THE else if goes on but still the same*****
  </code></pre>
  
  <p>So I'm planning to automatically Pick a section depending on the students grade, I am planning to put this code in each of the if statements above. Like this:</p>
  
  <pre><code>    else if( $get_display-&gt;level== "Grade 1"){
          $lbl="Grade 2";
                   if($get_display-&gt;gpa =&gt; "88"){ 
         $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
         and section_name="A"");
         $row = mysql_fetch_array($result);
                 $sname = $row['section_name'];
                 }else if($get_display-&gt;gpa =&gt; "80"){ 
         $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
         and section_name="B"");
         $row = mysql_fetch_array($result);
                 $sname = $row['section_name'];
         }else if($get_display-&gt;gpa =&gt; "75"){ 
         $result = mysql_query("SELECT * FROM tbl_section where level='$lbl' 
         and section_name="C"");
         $row = mysql_fetch_array($result);
                 $sname = $row['section_name'];                        
                      }
          }
  </code></pre>
  
  <p>And <strong>$sname</strong> would be used here:</p>
  
  <pre><code>    &lt;input type="text"  name="levele" value="&lt;?php echo $sname;?&gt;"&gt;
  </code></pre>
  
  <p>My main problem now is what if <strong>section a</strong> is full , it should automatically insert to <strong>section b</strong> right? how should i be able to do that? and should i add a field in my <strong>tbl_section</strong> to count the student who are in? And if i would tamper my DB how should it look?would appreciate any help. 
  (pls don't mention my DB is very compromised, already know that just a simple project but i will implement mysql_real_escape_string() later on, don't have the knowledge on mysqli yet.)</p>
  
  <p>EDIT: <strong>section a and b</strong> are just field names in my Database here is what <strong>tbl_section</strong> looks like.</p>
  
  <pre><code>     section_id (int)
       section_name(vchar)(default names are A,B,C and cannot be changed)
       sy (school year) 
       adviser_id
       level
  </code></pre>
  
  <p>Sorry first time to show my db here hope this is correct.</p>