Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2288
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: pagination driving me insane |
| Date | 2011-06-22 06:34 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <itsger$ghs$1@dont-email.me> (permalink) |
| References | <c37ec843-dead-44f9-95be-cabfec77dfb1@d42g2000yqa.googlegroups.com> <itrjdm$rgu$1@dont-email.me> <c43fb6be-a752-4d3f-83d2-c831da6ae82a@c20g2000vbv.googlegroups.com> |
On 6/22/2011 1:02 AM, Co wrote:
> On 22 jun, 04:18, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 6/21/2011 5:22 PM, Co wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> Hi All,
>>
>>> I have a page which displays accounts. On the page there are three
>>> search options:
>>
>>> 1. sort by newest members first;
>>> 2. search by country;
>>> 3. search by name;
>>
>>> There is a limit of 10 accounts per page. If the query returns more
>>> than 10 records I have to browse to the next page.
>>> So I need to save the search options in the url when I go to the next
>>> page. I tried the following code but it doesn't work properly:
>>
>>> // check if any of the three buttons were clicked
>>> if(isset($_POST['listByq']) {
>>
>>> // did I click the search by country button
>>> if ($_POST['listByq'] == "by_country") {
>>
>>> $value = $_POST['country']; //put the country name in the
>>> variable for the URL
>>> $country = $_POST['country'];
>>> $queryString = "WHERE country='$country' AND email_activated='1'";
>>> $choice = $_POST['listByq']; } //put by_country in the variable
>>> for the URL
>>
>>> // did I click on the searh by firstname
>>> else if ($_POST['listByq'] == "by_firstname") {
>>
>>> $value = $_POST['fname'];
>>> $firstname = $_POST['fname'];
>>> $firstname = mysql_real_escape_string($firstname);
>>> $queryString = "WHERE firstname LIKE '%$firstname%' OR lastname
>>> LIKE '%$firstname%' AND email_activated='1'";
>>> $choice = $_POST['listByq'];
>>
>>> // or did I click the newest members first sort order
>>> } else if ($_POST['listByq'] == "newest_members") {
>>
>>> $value = "";
>>> $queryString = "WHERE email_activated='1' ORDER BY id DESC";
>>> $choice = $_POST['listByq'];
>>> }
>>> }
>>
>>> // now get the values form the URL
>>> if (isset($_GET['choice'])) {
>>> $choice = $_GET['choice'];
>>> $value = $_GET['value'];
>>> }
>>
>>> // if there was anything in $choice
>>> if ($choice<> "") {
>>> if($choice = "by_country") {
>>> $country = $value;
>>> $queryString = "WHERE country='$country' AND
>>> email_activated='1'";
>>> else if ($choice= "by_firstname") {
>>> $firstname = $value;
>>> $queryString = "WHERE firstname LIKE '%$firstname%' OR lastname
>>> LIKE '%$firstname%' AND email_activated='1'";
>>> $queryMsg = "Showing Members with the name you searched for"; }
>>> else if ($choice= "newest_members") {
>>> $queryString = "WHERE email_activated='1' ORDER BY id DESC";
>>> }
>>
>>> }
>>
>>> The pagination looks like this:
>>> $centerPages .= ' <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
>>> $add1 . '&choice=' . $choice . '&value=' . $value . '">' . $add1 .'</
>>> a> ';
>>
>>> I know there must be a solution for this which works but I have looked
>>> at it from all sides but I don't get it.
>>> Does anyone know how to get this working?
>>
>>> Marco
>>
>> Are you doing a GET or a POST? You're using both in your code - which
>> is highly unusual.
>>
>
> I know. Initially I was doing a post when I click one of the buttons.
> The country search, search by name or search by newest members.
> With the GET I was trying to get the values I put into the URL when I
> go to the next page.
> I have been struggling with this code the whole day but I can't seem
> to get it right.
>
> Marco
So, make up your mind. Do GET or POST - don't try to do both.
And once again - look at what you have in your $_GET and $_POST arrays,
and use them to trace through the code. Figure out what it's doing.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-21 14:22 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-21 22:18 -0400
Re: pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-21 22:02 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-22 06:34 -0400
Re: pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-22 05:50 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-22 10:54 -0400
Re: pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-22 09:57 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-22 13:17 -0400
Re: pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-23 10:24 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-23 13:27 -0400
Re: pagination driving me insane Co <vonclausowitz@gmail.com> - 2011-06-23 11:08 -0700
Re: pagination driving me insane Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-23 15:03 -0400
csiph-web