title: Retrieving specific value from a database php
body: <p>I have a college project where users are able to register and login to a website. I have it set up so when registering a user enters their username, email, password, confirm password, address, and phonenumber. Once registered they are assigned a random string value, lets call it $randomString.</p>
  
  <p>So my database is login_db and it contains the table user. The table headings are username, email, password, address, phonenumber, randomstring.</p>
  
  <p>Its running fine a user can register, their details are added to the database and a user can login. When they log in they are redirected to admin.php. This page is blank at the moment. </p>
  
  <p>Remember the $randomString people are assigned? I need to go into the database retrieve $randomString and display on admin.php.</p>
  
  <p>This is what I've tried so far, I've only been able to display all users random strings but i need only the logged in users randomString. So im presuming the steps i need to go through are<br>
  1. Check IF user is logged in. maybe ----> if(isset($_SESSION['email']) ???? <br>
  2. Check WHAT user is logged in. ????<br>
  3. Retrieve logged in users randomString.  ????<br>
  4. Display the random string. maybe ----> echo $result ???</p>
  
  <p>I have absolutely zero idea how to do it so all help is appreciated.</p>
  
  <pre><code>$connection = mysqli_connect('localhost', 'root', '', 'login_db');
  
  if($connection) {
  echo "we are connected";
  } else {
  die("Database connection failed");
  }
  
  
  ?&gt;
  
  
  &lt;div class="jumbotron"&gt;
  &lt;h1 class="text-center"&gt;&lt;?php
  
  $query = "SELECT randomString FROM users";
  
  $result = mysqli_query($connection, $query);
  
  while ($row = mysqli_fetch_row($result)) {
  
  print_r($row);
  
  }
  
  ?&gt;&lt;/h1&gt;
  &lt;/div&gt;
  </code></pre>