text: Q:
  
  Trying to output the richest user in my database through php
  
  I know this is a bit of a rookie question but I'm trying to output the richest user's name on my website.
  So my table is called Users
  I have Column 1 ('Name') containing the names of all the users, and Column 2 ('Bank') containing their account balance.
  I would like to find the richest user and output them on my website.
  This is what I've got so far.
  while ($row2 = mysqli_fetch_array($sqldataGang, MYSQLI_ASSOC)) {
      $sqlgetGang = 'select name from gangs where bank = (select max(bank) from gangs) order by bank;';
      $sqldataGang = mysqli_query($dbcon, $sqlgetGang) or die('Connection could not be established');
      $welthiestGang = $row2['name'];
  }
  
  I know that there is a connection to the database as I have other statistics from other tables working... I have no idea why this isn't working... Thanks for the help in advance :) 
  
  A:
  
  You need to fetch a row from your $sqldataGang query object.
  Add a line something like this to your program to fetch the result right after your call to mysqli_query()
  $row2 = mysqli_fetch_array($sqldataGang, MYSQLI_ASSOC);
  
  But, also, beware. A wise programmer always checks queries for errors. You can see how to do that in the examples here.
  
  