diff options
Diffstat (limited to 'www/youtube_functions.php')
| -rw-r--r-- | www/youtube_functions.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/www/youtube_functions.php b/www/youtube_functions.php index 15153ec..17a8964 100644 --- a/www/youtube_functions.php +++ b/www/youtube_functions.php @@ -23,13 +23,18 @@ function searchterm(){ $table_array = array("english", "german"); $table_count = count("$table_array"); - - $rows = $db->query("SELECT count(*) as count FROM german;"); + + $table=$table_array[0]; + + $rows = $db->query("SELECT count(*) as count FROM ". $table . ";"); $row = $rows->fetchArray(); $numRows = $row["count"]; - - $search_word = mt_rand(1,$numRows); + + $random = mt_rand(1,$numRows); + $search_word_db = $db->query("SELECT word FROM " . $table . " WHERE id=" . $random . ";"); + $search_word_ar = $search_word_db->fetchArray(); + $search_word = $search_word_ar["word"]; return $search_word; } |
