从sql mtouch测验中选择随机行

| 我在尝试使用基于测验(WordPress插件)的mtouch测验设置测验时遇到问题,我需要从数据库中选择一个正确的答案和3个随机答案。 ID--question_id ------ answer -----提示-----正确------ sort_order 1 -------- 1 ----------------- test1 --------------------- 1-- -------------- 1 2 -------- 1 -----------------测试1 --------------------- 0- --------------- 2 3 -------- 1 ----------------- test2 --------------------- 0-- -------------- 3 4 -------- 1 ------------------- test3 --------------------- 0-- -------------- 4 5 -------- 2 -----------------测试5 --------------------- 1-- -------------- 1 以上是sql结构的示例,我想做的是摆脱错误的答案,并使用其他问题的正确答案并使它们成为错误的答案,即问题1 http://wordpress.org/extend/plugins/mtouch-quiz/ 我只需要现在如何编辑show_quiz.php文件即可做到这一点。 如果($ random_answers == 1){                                                     $ dans = $ wpdb-> get_results(\“选择ID,answer,更正,提示来自{$ wpdb-> prefix} mtouchquiz_answer WHERE question_id = {$ ques-> ID} ORDER BY RAND()\”); //这将随机回答问题                                                 }其他{                                                     $ dans = $ wpdb-> get_results(\“选择ID,answer,更正,提示来自{$ wpdb-> prefix} mtouchquiz_answer WHERE question_id = {$ ques-> ID} ORDER BY sort_order \”);                                                 } 谁能帮忙。谢谢     
已邀请:
这将为您提供其他问题的3个正确答案 选择* FROM {$ wpdb-> prefix} mtouchquiz_answer WHERE question_id!= {$ ques-> ID}并更正= 1 ORDER BY RAND()限制为0.3     

要回复问题请先登录注册