php - Get Random values from mySQL -
i have table columns subjects,questions,exam,question id
, table want random values display.
for every every question have used:
$singlesql = mysql_query("select * questions id='$question' order rand() limit 1");
for every subject:
$singlesql = mysql_query("select * questions id='$question' , subject='ayooooo' order rand() limit 1");
i want display random questions when ever page loads , hen next question asked.
quiz.php?question='
how should use here?
javascript:
function getquestion() { var hr = new xmlhttprequest(); hr.onreadystatechange = function () { if (hr.readystate == 4 && hr.status == 200) { var response = hr.responsetext.split("|"); if (response[0] == "finished") { document.getelementbyid('status').innerhtml = response[1]; } var nums = hr.responsetext.split(","); document.getelementbyid('question').innerhtml = nums[0]; document.getelementbyid('answers').innerhtml = nums[1]; document.getelementbyid('answers').innerhtml += nums[2]; } } hr.open("get", "questions.php?question=" + <? php echo $question; ?> , true); hr.send(); } function x() { var rads = document.getelementsbyname("rads"); (var = 0; < rads.length; i++) { if (rads[i].checked) { var val = rads[i].value; return val; } } } function post_answer() { var p = new xmlhttprequest(); var id = document.getelementbyid('qid').value; var url = "useranswers.php"; var vars = "qid=" + id + "&radio=" + x(); p.open("post", url, true); p.setrequestheader("content-type", "application/x-www-form- urlencoded"); p.onreadystatechange = function () { if (p.readystate == 4 && p.status == 200) { document.getelementbyid("status").innerhtml = ''; var url = 'quiz.php?question=<?php echo $next; ?>'; window.location = url; } } p.send(vars); document.getelementbyid("status")
Comments
Post a Comment