Multi-condition query results page paging problems ???????? Construct a query condition REQ
$ Show_m_dep = trim ($ _ GET ['show _ m_dep ']);
$ Show_m_pro = trim ($ _ GET ['show _ m_pro']);
$ Show_m_con = trim ($ _ GET ['show _ m_con ']);
$ Show_m_tim1 = trim ($ _ GET ['show _ m_tim1 ']);
$ Show_m_tim2 = trim ($ _ GET ['show _ m_tim2 ']);
$ Show_m_kin = trim ($ _ GET ['show _ m_kin ']);
Echo $ _ GET [show_m_pro];
$ Req = "1 ";
// Construct search condition 1
If ($ _ GET [show_m_dep] = "99" | empty ($ _ GET [show_m_dep])
{
// If it is null, the query conditions remain unchanged
}
Else
$ Req. = "and M_dep = '$ _ GET [show_m_dep]'";
// Construct search condition 2
If (empty ($ _ GET [show_m_pro])
{
// If it is null, the search criteria remain unchanged
}
Else
$ Req. = "and M_pro like '% $ _ GET [show_m_pro] % '";
// Condition 3
If (empty ($ _ GET [show_m_con])
{
// If it is null, the search criteria remain unchanged
}
Else
$ Req. = "and M_con like '% $ _ GET [show_m_con] % '";
// Condition 4
$ Temptime = "";
If ($ _ GET [show_m_tim1]! = "99 "&&(! Empty ($ _ GET [show_m_tim1])
{
$ Temptime. = $ _ GET [show_m_tim1];
If ($ _ GET [show_m_tim2]! = "99 ")
{
$ Temptime. = $ _ GET [show_m_tim2];
}
$ Req. = "and M_tim like '$ _ GET [temptime] %'"; // only the year or year month has
}
// Condition 5
If ($ _ GET [show_m_kin] = "99" | empty ($ _ GET [show_m_kin])
{
// If it is null, the search criteria remain unchanged
}
Else
$ Req. = "and M_kin like '$ _ GET [show_m_kin]'";
$ _ SESSION [Req] = $ Req;
_____________________ Query the printed table content
$ SQL = "select count (M_id) from myfile WHERE $ Req ";
.....
????????? Pagination page link
For ($ I = 1; $ I <= $ pageCount; $ I ++)
{Echo "$ I ";
}
____________
The general code is as above. because the get content on the previous interface may not be used during Req construction, the Req cannot be spelled out using several GET values in the link on the page, it does not seem to work with SESSION storage. when the page number jumps, the req changes back to the initial 1, therefore, I would like to ask how to write the query conditions in this case to save the query conditions during page navigation?
Reply to discussion (solution)
Didn't you already use session to save it?
Didn't you already use session to save it?
Saved, but the req value is returned to 1 when the page number link jumps below ..
No session_start ();?
In addition, after turning the page, it is not calculated from $ _ GET, but directly from the session.
If you pass query conditions in the url, what do you need to save?
Use $ _ GET ['req '].
Directly use the url to pass the parameter. the query condition and page number can be used to pass the parameter through the URL and obtain the parameter. it is better to analyze the logic of the function you want to implement.
After checking the URL of each jump, we found the problem...
The problem is solved by getting the previous url with _ server. Thank you for your guidance.