The title is already self-explanatory. I've tried everything, but I feel like everything I've done is completely wrong, haha. If anyone can help me, I need to do a dropdown where the values to be selected will be names of the tables in my database. Thank you.
[EDIT] The easiest way I see is to pull all the tables through the mysqli_list_tables function and then I would use a while, or to print this in the dropdown. The point is that even this simple function below is not working. I've tried leaving only the fundamental part (the function of listing tables) for testing purposes and even then, nothing works. (Even in my index file, after calling the dropdownAnos () function nothing else works.)
function dropdownAnos () {
$host = "localhost";
$user = "root";
$pass = "root";
$banco = "teste";
mysqli_connect($host, $user, $pass);
$tabelas = mysqli_list_tables($banco);
print_r($tabelas);
}
I've changed this code countless times, tried every way possible and this was the simplest version I could get. Even so, it does not work. (Good thing I've saved in github, otherwise I would have lost everything haha.)
[FINAL EDIT] I was able to do it, people. I'll post the answer, should anyone fall into this topic:
function dropdownAnos () {
$str = "";
$db = new mysqli('localhost', 'root', 'root', 'teste');
$teste = $db->query('SHOW TABLES');
while ($t = $teste->fetch_array()) {
$str = $str . "<option>" . $t[0] . "</option><br>";
}
echo $str;
}
Thanks to all who helped.