I'm trying to get the first 3 occurrences (rows) in a MySQL table (column specified) that start with a user-provided string:
$con = mysqli_connect($db_host, $db_user, $db_password, $db_name);
$user_input = $_POST['user_input'];
$result = mysqli_query($con, "SELECT * FROM airports WHERE airport_name LIKE '$user_input%' LIMIT 3") or die();
$row = mysqli_fetch_array($result);
$airport_suggestion1 = $row[1];
$airport_suggestion2 = $row[2];
$airport_suggestion3 = $row[3];
For some reason this will only return the first row found, $airport_suggestion2 and $airport_suggestion3 are always empty even when they shouldn't be. What am I doing wrong here?