title: Size of a table in mysql php
body: <p>I have table calle users_session which I want it to hold only 8 rows. I am trying to implement my code so that if the number of rows is 8 the user is not added but if it is less the user is added. The problem is that it seems as if the code after the while loop not the one inside does not work. </p>
  
  <p>Basically want I am trying to achieve is that is the user is already in the table he is let  in the game, if he is not and the table is full, a message is displayed saying it is full, and if the user is not in the table but it is not full he is added to the table.</p>
  
  <p>Thank you, hope someone can help me!</p>
  
  <pre><code>&lt;?php session_start();
  $member_id = $_SESSION['member'];
  
  // establishing connection to the database
  
  require ('database_connection.php');
  
  $my_database = mysql_select_db("roulette") or die("Database wasn't found!");
  
  // counting the number of rows in the users_session table
  
  $count_rows = "SELECT * FROM users_session";
  $count_rows_query = mysql_query($count_rows) or die("&lt;p&gt; &lt;font face=verdana&gt; selecting rows failed!&lt;/p&gt;");
  $number_of_rows = mysql_num_rows($count_rows_query) or die("&lt;p&gt; &lt;font face=verdana&gt; Counting rows failed!&lt;/p&gt;");
  
  // getting the contents of the table users_session
  
  $query = "SELECT * FROM  users_session";
  $select_query = mysql_query($query) or die("&lt;p&gt; &lt;font face=verdana&gt; Fetching rows failed!&lt;/p&gt;");
  $isAlready = false;
  
  // fetch and check every row in the table
  
  while ($rows = mysql_fetch_array($select_query))
      {
  
      // if the user is already inside the session
  
      if ($member_id == $rows['member_id'])
          {
          $isAlready = true;
          print "&lt;script&gt; alert('You are already listed in the session') &lt;/script&gt;";
          include ('one_number_bet.php');
  
          }
        else
          {
          $isAlready = false; //user is not in the session
          }
      }
  
  print "test";
  print $number_of_rows;
  
  // if user is not in the session
  
  if ($isAlready = true)
      {
  
      // checking if the table is full
  
      if ($number_of_rows &lt; 8)
          {
          print "&lt;script&gt; alert('The session is full, please try again later') &lt;/script&gt;";
          include ("type_of_bet.php");
  
          }
  
      // table is not full
  
        else
          {
  
          // add the user in the session
  
          $query = "INSERT INTO users_session (member_id) VALUES ('$member_id');";
          $insert_query = mysql_query($query) or die("&lt;p&gt; &lt;font face=verdana&gt; Insertion failed!&lt;/p&gt;");
          print "&lt;script&gt; alert('You have been successfully added to the session') &lt;/script&gt;";
          include ("one_number_bet.php");
  
          }
      }
  
  ?&gt;
  </code></pre>