I try to show the user country and field that saved in the database by using the following code but I keep getting this error that said
Fatal error: Uncaught Error: Notice: Undefined index: country in C:\xampp\htdocs\LIVE TAG\custom_import.php on line 26
Notice: Undefined index: country in C:\xampp\htdocs\LIVE TAG\custom_import.php on line 26
Notice: Undefined index: field in C:\xampp\htdocs\LIVE TAG\custom_import.php on line 35
Notice: Undefined index: field in C:\xampp\htdocs\LIVE TAG\custom_import.php on line 35
and also here is the before and next side of the code
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "uni";
///////////
//Filter data from here so we can search the exact column that we want to
$connect = mysqli_connect($servername, $username, $password, $dbname);
$country = '';
$field = '';
$qu = "SELECT DISTINCT field FROM csv ORDER BY field ASC";
$query = "SELECT DISTINCT Country FROM csv ORDER BY Country ASC";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetch_all(); // LINE 22
foreach ($result as $row) {
$country .= '<option value="' . $row['country'] . '">' . $row['country'] . '</option>'; //LINE 26
}
$field = '';
$state = $connect->prepare($qu);
$state->execute();
$res = $state->fetchAll();
foreach ($res as $row) {
$field .= '<option value="' . $row['field'] . '">' . $row['field'] . '</option>'; //LINE 35
}
//rest of the code