在多个页面上的Php MYSQL查询

I have developed a Php & Mysql data-driven website "Student Progress Report Portal". Its navigation bar contains 3 links for Page 1, Page 2 and Page 3. Page 1 Shows: Student Progress overall test results percentage summary (by default its mysql select query is from the class starting date to to-Date), and Page 1 also has two date type textboxes, Progress Report Button to show student test progress datewise on "Page 2" and Attendance Button to show Date Wise Attendance on Page 3.

By direct clicking on Page 2 link, and Page3 link it shows nothing because first, we have to select dates on page 1 and then have to click on Progress Button or Attendance Button to fetch the "mysql base query result" on Page2 and Page3 respectively. After getting the result on Page 2, and Page 3 when the user clicks on Page 2 and Page 3 link on navigation bar it gets refresh and the result disappears. I want both (Page 2 & 3) to remain on the same results despite clicking to their links on the navigation bar. How can solve this issue ?

You can use JavaScript for don't refresh the page when you click on Page2 or Page3 like a 'tab' in Bootstrap -> Bootstrap tab ( in the middle of the page )

Or, you can dow a system where you click on page 1, it will get only the first 20 elements that you need, on page 2 the 21th element to the 40th element ... And you make a COUNT(*) request for know how many pages you will have.

@user2332060,

What I have understood from you description is that you need different results on all three pages: I would recommend to use jQuery and ajax to achieve that.

When results load on Page 1 with mysql query(fromdate to todate) you have those dates, when you click on Page2 or Page3 call ajax function and pass those dates or if user select any date pass that in ajax and load results in Page 3 and Page 3 accordingly.

Now when you reload or refresh Page 2 or Page 3 you said results disappear because you never informed your script where to fetch data from, so try to put windows onload function in jquery and use your default mysql query for each respective pages.

Hope this helps!

If i understood your question correctly, what you are trying to do is pass what was selected on Page 1, so that that selection holds for Page 2 and Page 3 ? If my understanding is correct, what you could do is pass or post your selection in the browser. For security purposes you could even hash it so it can't be intercepted. Below is a brief shuffle at what you could do, if i understood your question right i could elaborate more on the below method.

Page 1:

if($_POST['date'] && ...){
$url="page2.php?dt=$_POST['date']";
}

Page 2:

$date=$_REQUEST['dt'];
$sql="... Where date='".$date."'";

You can use session or environment variables to do it, as you redirect from page1 to page2 with custom selected dates, you can store them in session variable.

$_SESSION['page2'] = $date;

Similarly, you can do for page3

$_SESSION['page3'] = $date;

Note : create different session key for both pages, and unset values in session variables each time page1 is loaded

unset($_SESSION['page2']);
unset($_SESSION['page3']);

Hope it will help you.