Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #2325
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: pagination driving me insane |
| Date | 2011-06-23 15:03 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <iu02me$cmv$1@dont-email.me> (permalink) |
| References | (6 earlier) <3a5c6d57-5f77-4ede-bb3d-ffe72c9296f9@d1g2000prg.googlegroups.com> <itt832$m12$3@dont-email.me> <3abdeca7-3ba2-49a3-92d1-463b43655f8c@l18g2000yql.googlegroups.com> <itvt2u$27r$1@dont-email.me> <a45c2f1f-edd5-4a48-bd06-3fe42ef4bafe@d14g2000yqb.googlegroups.com> |
On 6/23/2011 2:08 PM, Co wrote:
> On 23 jun, 19:27, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 6/23/2011 1:24 PM, Co wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> On 22 jun, 19:17, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>>>> On 6/22/2011 12:57 PM, Co wrote:
>>
>>>>> On 22 jun, 17:54, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>>>>>> On 6/22/2011 8:50 AM, Co wrote:>>> 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.
>>
>>>>>> > Jerry,
>>
>>>>>> > i need the POST to search in my members accounts.
>>>>>> > The problem is that PHP loses the query I run when I goto the next
>>>>>> > page.
>>>>>> > I preferred using a session variable but I wasn't able to get rit of
>>>>>> > the variable after I filled it. So everytime when I come back to the
>>>>>> > page it will automatically use the session variable again.
>>>>>> > Or is there a way to clear the session variable when I load the page?
>>
>>>>>> > Marco
>>
>>>>>> <Top posting fixed>
>>
>>>>>> No, it's no longer there because the browser didn't send it. PHP didn't
>>>>>> lose anything. From the browser's point of view, each page is a new
>>>>>> request to the server, and the browser sends only what you tell it to send.
>>
>>>>>> What you need to do is determine if this a new search or a continuation
>>>>>> of the previous search (i.e. display the next page). If the former,
>>>>>> clear your old $_SESSION values (if any) and put new ones in there and
>>>>>> display the first page. If the latter, use the data stored in the
>>>>>> $_SESSION and display the next page of the search.
>>
>>>>>> There are any number of ways to determine if it is a continuation page;
>>>>>> i.e. the $_GET or $_POST value has "page=next" or "page=3" in it; the
>>>>>> current page number is in a hidden field in the form or similar. A new
>>>>>> search wouldn't have those values.
>>
>>>>> I will try to work on that.
>>>>> But can I clear the session before I open the page so that an
>>>>> older session that I used ealier will be cleared until I hit the
>>>>> submit button? I don't want to clear the whole sessions just the one
>>>>> variable.
>>
>>>>> Marco
>>
>>>> You can unset() any element you want in the $_SESSION array. But you
>>>> can't do ANYTHING until the user requests a page - your code doesn't get
>>>> invoked until that time.
>>
>>>> --
>>>> ==================
>>>> Remove the "x" from my email address
>>>> Jerry Stuckle
>>>> JDS Computer Training Corp.
>>>> jstuck...@attglobal.net
>>>> ==================
>>
>>> I have been trying the following code but I get an error when I click
>>> the next page on my form:
>>
>>> if(isset($_POST['listByq'])&& $_POST['listByq'] != "add") {
>>> unset($_SESSION['listByq']);
>>> $option = "";
>>> $_SESSION['listByq'] = $_POST['listByq'];
>>> }
>>
>>> if(isset($_SESSION['listByq'])) {
>>> $option = $_SESSION['listByq'];
>>> if ($option == "by_country") {
>>
>>> $country = $_POST['country'];
>>
>>> $queryString = "WHERE country='$country' AND email_activated='1'";
>>> $queryMsg = "Showing Members from the country you searched for";
>>
>>> } else if ($option == "by_firstname") {
>>
>>> $firstname = $_POST['fname'];
>>> $firstname = stripslashes($firstname);
>>> $firstname = strip_tags($firstname);
>>> $firstname = eregi_replace("`", "", $firstname);
>>> $firstname = mysql_real_escape_string($firstname);
>>> $queryString = "WHERE rank LIKE '%$firstname%' OR firstname LIKE '%
>>> $firstname%' OR lastname LIKE '%$firstname%' AND email_activated='1'";
>>> $queryMsg = "Showing Members with the name you searched for";
>>
>>> } else if ($option == "newest_members") {
>>
>>> $queryString = "WHERE email_activated='1' ORDER BY id DESC";
>>> $queryMsg = "Showing Newest to Oldest Members";
>>> }
>>
>>> } // end of if(isset($_SESSION....
>>
>>> Notice: Undefined index: fname
>>
>>> When the POST has been done there is no problem but after that it
>>> doesn't recognise fname or country anymore.
>>
>>> Marco
>>
>> That's because they weren't in the form, so the browser can't send them.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> Hmmm,
>
> I created a second SESSION variable like $_SESSION['ValueByq']
> this one holds either the country value or the fname value.
>
> if(isset($_POST['listByq'])&& $_POST['listByq'] != "add") {
> unset($_SESSION['listByq']);
> unset($_SESSION['valueByq']);
> $option = "";
> $_SESSION['listByq'] = $_POST['listByq'];
> if(isset($_POST['fname'])) { $_SESSION['valueByq'] =
> $_POST['fname']; }
> if(isset($_POST['country'])) { $_SESSION['valueByq'] =
> $_POST['country']; }
> }
>
> The only thing I don't know is what will happen when i login, go to
> this page and the
> session variables don't exist yet?
>
> Marco
You need to test to see if they are set or not using isset(), like you
are with your $_POST values. And if they aren't set, take the
appropriate action.
--
==================
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 | 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