From 0718ff72472754e6116ad58f4ff6bc788f5c3d61 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 26 Feb 2014 17:25:43 +0100 Subject: It works! --- www/youtube_functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'www/youtube_functions.php') 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; } -- cgit v1.2.3