-4

function preventBack(){window.history.forward();} setTimeout("preventBack()", 0); window.onunload=function(){null}; query("SELECT * FROM exam_tbl WHERE ex_id='$examId' ")->fetch(PDO::FETCH_ASSOC); $selExamTimeLimit = $selExam['ex_time_limit']; $exDisplayLimit = $selExam['ex_questlimit_display']; //pagination...//total records per page$numperpage = 1;

//count the total page number$countsql = $conn->prepare("SELECT COUNT(eqt_id) FROM exam_question_tbl WHERE exam_id='$examId'");//$countsql = $conn->prepare("SELECT * FROM (exam_question_tbl) WHERE exam_id='$examId'");$countsql->execute();$row = $countsql->fetch();$numrecords = $row[0];$numlinks = ceil($numrecords/$numperpage);echo "Number of pages : ".$numlinks;$page = $_GET['start'];if(!$page) $page = 0; $start = $page * $numperpage;echo "Start is ".$start.'
'; ?>

input type="hidden" name="" id="timeExamLimit" value=""> Remaining Time : -->

"> query("SELECT * FROM exam_question_tbl WHERE exam_id='$examId' LIMIT 1 "); // $selQuest = $conn->query("SELECT * FROM exam_question_tbl WHERE exam_id='$examId' ORDER BY rand() LIMIT 1 "); $selQuest = $conn->query("SELECT * FROM exam_question_tbl WHERE exam_id='$examId' LIMIT $start, $numperpage"); // $selQuest = $conn->query("SELECT * FROM exam_question_tbl WHERE exam_id='$examId' ORDER BY rand() LIMIT $exDisplayLimit "); if($selQuest->rowCount() > 0) { // $i = 1; while ($selQuestRow = $selQuest->fetch(PDO::FETCH_ASSOC)) { ?> .) --> ][correct]" value="" class="form-check-input" type="radio" value="" id="invalidCheck" > ][correct]" value="" class="form-check-input" type="radio" value="" id="invalidCheck" > ][correct]" value="" class="form-check-input" type="radio" value="" id="invalidCheck" > ][correct]" value="" class="form-check-input" type="radio" value="" id="invalidCheck" > ][correct]" value="" class="form-check-input" type="radio" value="" id="invalidCheck" > $numperpage * $start; for($i=0;$i<$numlinks;$i++){ $y = $i+1; echo ''.$y.' '; } ?>

td style="padding: 20px;"> Reset No question at this moment

Greetings to everyone committed to this unique discussion thread. Please, can anyone help me, i need to add an Ajax to this pagination buttons for previous, and next buttons. When clicked, it doesn't refresh till it gets to the last id. Is a CBT project...

  • 1
    Welcome to Stackoverflow. Please take the [tour] and read [ask] (as the system recommended you to do before posting, but I can see from the lack of badge in your profile that for some reason you did not). Then also please read how to make a [mre] of your issue, as well as [How do I format my posts?](https://stackoverflow.com/help/formatting) and [Why is “Can someone help me?” not an actual question?](https://meta.stackoverflow.com/questions/284236/why-is-can-someone-help-me-not-an-actual-question) and try again. You can [edit] your post. – ADyson Sep 01 '23 at 10:36
  • 1
    You need to ask a specific question about a specific problem within your attempt to research, design and implement the code to try and meet your requirement. Otherwise we don't know how best to help you, or what your level of knowledge is, or where you're getting stuck with the problem. Nor does your post really contain enough context which we could use to integrate pagination code correctly anyway. And if by "help", you actually mean "write it all for me", that's not what this site is about. Thanks. – ADyson Sep 01 '23 at 10:37
  • P.S. **Warning:** Your code is vulnerable to SQL Injection attacks. You must use prepared statements **with parameters** to help prevent attackers from compromising your database by using malicious input values. http://bobby-tables.com gives an explanation of the risks, as well as some examples of how to write your queries safely using PHP / PDO. So far, you've only done half the job! **Never** insert unparameterised data directly into your SQL. The way your code is written now, someone could easily steal, incorrectly change, or even delete your data. – ADyson Sep 01 '23 at 10:40
  • https://phpdelusions.net/pdo also contains good examples of writing safe SQL using PDO. See also: [How can I prevent SQL injection in PHP?](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) . Parameterising your queries will also greatly reduce the risk of accidental syntax errors as a result of un-escaped or incorrectly quoted input values. Pay closer attention to these examples so that you understand the parameterisation part. A prepared statement by itself is not sufficient. – ADyson Sep 01 '23 at 10:41

0 Answers0