AutoComplete / Suggestions / MySQL

0

Question 1: Does anyone have any working example of when someone types in an input suggestions below? preferably from a table created in mysql.

  

Bank: test   Table: users (user_id, user_email).

Question 2: In an "option value" how could I do to sort in descending order?  From this:

  <td class="KT_th"><label for="user_id">Nome de Usuário:</label></td>
  <td><select name="user_id" id="user_id">
    <?php
do {  
?>
    <option value="<?php echo $row_Rsmostrar['user_id']?>"<?php if (!(strcmp($row_Rsmostrar['user_id'], $row_Rsmostrar['user_nome']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Rsmostrar['user_nome']?></option>
    <?php
} while ($row_Rsmostrar = mysql_fetch_assoc($Rsmostrar));
  $rows = mysql_num_rows($Rsmostrar);
  if($rows > 0) {
  mysql_data_seek($Rsmostrar, 0);
  $row_Rsmostrar = mysql_fetch_assoc($Rsmostrar);
  }
?>
    
asked by anonymous 03.02.2018 / 03:56

1 answer

0

1 question, you could even use Jquery UI, as @dvd spoke.

2 question, to pick in descending order, make this logic

$listaUsuarios = //array de usuarios da tabela;

$amount = count($listaUsuarios); //quantidade de usuarios

for ($i = $amount; $i >= $amount; $i--) {
    //aqui voce faz a logica do <select>
    <option>
        echo $listaUsuarios[$i]; //vai fazer na ordem decrescente
    </option>
}

Just a logic, you implement your

Here's Jquery UI: link

    
03.02.2018 / 04:50