diff options
| author | root | 2014-02-26 17:25:43 +0100 |
|---|---|---|
| committer | root | 2014-02-26 17:25:43 +0100 |
| commit | 0718ff72472754e6116ad58f4ff6bc788f5c3d61 (patch) | |
| tree | 4d4e243b4f5eb2fb24efb3e975a498d47f25c9f2 /www/youtube_functions.php | |
| parent | 01e3fb742f09593532e5db5f3c780577c1ca2dec (diff) | |
| download | random-0718ff72472754e6116ad58f4ff6bc788f5c3d61.tar.gz | |
It works!
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; } |
