summaryrefslogtreecommitdiff
path: root/www/youtube_functions.php
diff options
context:
space:
mode:
authorroot2014-02-26 17:25:43 +0100
committerroot2014-02-26 17:25:43 +0100
commit0718ff72472754e6116ad58f4ff6bc788f5c3d61 (patch)
tree4d4e243b4f5eb2fb24efb3e975a498d47f25c9f2 /www/youtube_functions.php
parent01e3fb742f09593532e5db5f3c780577c1ca2dec (diff)
downloadrandom-0718ff72472754e6116ad58f4ff6bc788f5c3d61.tar.gz
It works!
Diffstat (limited to 'www/youtube_functions.php')
-rw-r--r--www/youtube_functions.php13
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;
}