如何从phpMyAdmin获取数据,具体取决于用户选择的难度级别

i am trying to get some words for my Hangman game from the database MySQL Databasedepending on which difficulty level the user selects difficulty levelsso if the user selects "easy" the only words i want it to select is just the words that have "easy" next to it from the database. right now it selects all the words as you can see in this image --> image. this is my difficulty page difficultyi hope i explaining this question properly so that everyone can understand me, if you don't understand what i am trying to say please let me know.

Use this

$difficulty = 'hard'; //Value based on user selection
$conn->prepare("SELECT 'word' FROM words_list WHERE difficulty= ? ORDER BY RAND() LIMIT 1");
$conn->bind_param("s", $difficulty);

In your query you should add a where clause

select word from word_list where difficulty = $difficulty order by  rand() limit 1

For this to work you need to pass the selection to $difficulty

Add WHERE difficulty = <user input> to your query like so:

SELECT word FROM word_list WHERE difficulty = ? ORDER BY RAND() LIMIT 1

The ? becomes the variable put in by the user when you bind the parameter using prepared statements like you are doing. Don't just put the variable in the string or use PHP string concatenation. Use $conn->bind_param('s', $user_selection);.

http://php.net/manual/en/mysqli-stmt.bind-param.php