Multi-condition query result page paging problem -------- construct query condition REQ $ show_m_deptrim ($ _ GET [show_m_dep]); $ show_m_protrim ($ _ GET [show_m_pro]); $ show_m_contrim ($ _ GET [show_m_con]); $ show_m_tim1trim ($ _ GET [show_m_t multi-condition query result page paging problem
-------- Construct the 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?
------ Solution --------------------
If you pass query conditions in the url, what do you need to save?
Use $ _ GET ['req '].
------ Solution --------------------
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.