下拉选择问题

The following dropdown is filled with data from sql database:

<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
    <select name="Select" id="vals" onchange="this.form.submit()" class="btn btn-warning">
        <option value="">-- Select Country --</option>
        <?php 
           $user=new User(); 
           $sql5=DB::getInstance()->get('country', array('user', '=', $user->data()->username)); 
           if (!$sql5->count()) {
             echo 'No data'; 
           } else { 
             foreach ($sql5->results() as $sql5) { ?>
               <option value="<?php echo $sql5->name;?>">
               <?php echo $sql5->name;?></option>';
        <?php }
           } ?>
    </select>
</form>
</div>

And a user selects from the dropdown so that the information connecting to the selected data is outputted:

<? php
if (isset($_POST['Select']) && !empty($_POST['Select'])) {

    $userSelection = $_POST['Select'];
    $sql = DB::getInstance() - > get('country', array('country', '=', $userSelection));
    if (!$sql - > count()) {
        echo 'no data';
    } else {
        foreach($sql - > results() as $sql) {
            echo 'data';
        }

When I click an option from the dropdown, nothing comes out. The problem is with the $userSelection, a whitespace problem. When I replace the $userSelection with ' China', the data comes out but when I tried, 'China' nothing came out, it only works if there's a whitespace in front of it. I also checked my database and there's no whitespace in the values.

foreach ($sql5->results() as $sql5) { ?>

You are trying to iterate $sql5->results() and setting the child with the same variable name as the parent, thus replacing the parent. On the other iteration you are doing the same... try:

<select name="Select" id="vals" onchange="this.form.submit()" class="btn btn-warning">
  <option value="">-- Select Country --</option>
  <?php 
  $user=new User(); 
  $sql5=DB::getInstance()->get('country', array('user', '=', $user->data()->username)); 
  if (!$sql5->count()) {
    echo '<option value="no-data">No data</option>'; 
  } else { 
    foreach ($sql5->results() as $item) { 
       echo '<option value="'.$item->name.'">'.$item->name.'</option>';
    }
 }
 ?>
</select>