title: Get multiple rows from phpmyadmin to Java using JSON
body: <p>Good evening everyone, until a few days ago I had never used PHP or JSON and I am finding trouble getting multiple rows from phpmyadmin to Java using JSON. I have manged to write the below code however this only gets the last row.</p>
  
  <p>I took a look at this post (<a href="https://stackoverflow.com/questions/18797413/how-to-encode-multiple-rows-from-mysql-into-json-using-php">how to encode multiple rows from mysql into json using php</a>) and had a go but have had no luck..</p>
  
  <pre><code>    &lt;?php
  
      $user = 'root';
      $pass = '';
      $db = 'uopuser';
  
      $con=mysqli_connect('localhost', $user, $pass, $db) or die('Unable to connect');
  
  
      $statement = mysqli_prepare($con, 'SELECT * FROM society');
      mysqli_stmt_execute($statement);
  
      mysqli_stmt_store_result($statement);
      mysqli_stmt_bind_result($statement, $society_id, $name, $email, $description);
  
      $society = array();
  
      while(mysqli_stmt_fetch($statement)){
          $society['society_id'] = $society_id;
          $society['name'] = $name;
          $society['email'] = $email;
          $society['description'] = $description;
      }
  
      echo json_encode($society);
  
      mysqli_stmt_close($statement);
  
      mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance!</p>