Questions about paging of the multi-condition query result page

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.