|
|
@@ -12,7 +12,8 @@
|
|
|
}
|
|
|
mysqli_set_charset($conn,'utf8');
|
|
|
|
|
|
- $sql = 'SELECT * FROM questions ORDER BY RAND() limit 1';
|
|
|
+ $sql = 'SELECT questions.id, question, answer, categoryId as category, name FROM questions INNER JOIN questionToCategory ON questions.id = questionToCategory.questionId INNER JOIN category on category.id = questionToCategory.categoryId ORDER BY RAND() limit 1';
|
|
|
+
|
|
|
$result = mysqli_query($conn, $sql);
|
|
|
|
|
|
$json = array();
|
|
|
@@ -21,8 +22,7 @@
|
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
$json = array('id' => $row['id'],
|
|
|
'question' => $row['question'],
|
|
|
- 'answer' => $row['answer'],
|
|
|
- 'category' => $row['category']);
|
|
|
+ 'answer' => $row['answer'];
|
|
|
}
|
|
|
$jsonString = json_encode($json);
|
|
|
echo $jsonString;
|