Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #2216 > unrolled thread

radio button change after going to next page

Started byCo <vonclausowitz@gmail.com>
First post2011-06-17 04:30 -0700
Last post2011-06-17 14:08 -0400
Articles 6 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  radio button change after going to next page Co <vonclausowitz@gmail.com> - 2011-06-17 04:30 -0700
    Re: radio button change after going to next page Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 09:02 -0400
      Re: radio button change after going to next page Co <vonclausowitz@gmail.com> - 2011-06-17 06:26 -0700
        Re: radio button change after going to next page Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 09:32 -0400
          Re: radio button change after going to next page Co <vonclausowitz@gmail.com> - 2011-06-17 09:12 -0700
            Re: radio button change after going to next page Jerry Stuckle <jstucklex@attglobal.net> - 2011-06-17 14:08 -0400

#2216 — radio button change after going to next page

FromCo <vonclausowitz@gmail.com>
Date2011-06-17 04:30 -0700
Subjectradio button change after going to next page
Message-ID<e200ae50-5cf3-4bad-86fe-167c9bf89d3f@c41g2000yqm.googlegroups.com>
Hi All,

I have a page which shows all users on our community.
We have two kinds of users Active members and Veterans.
I have a radiobutton on my page to switch from Active Members to
Veterans or vv.
However when I choose Veterans and have to click to a next page the
radiobutton gets updated again
and jumps back to Active Member, so showing the active members again
in stead of the veterans.

Is there a way to prevent this from happening?
Here is what I do:

if(isset($_POST['submit1'])) {
   $status_account = $_POST['status'];
   if($status_account=='1') {
		$status_active = 'checked';
		$queryString = "WHERE email_activated='1' AND active='1' AND
country='" . $_SESSION['Origin'] . "' ORDER BY id ASC"; }
    else {
		$status_veteran = 'checked';
		$queryString = "WHERE email_activated='1' AND active='0' AND
country='" . $_SESSION['Origin'] . "' ORDER BY id ASC";
		}
}  else {

$queryString = "WHERE email_activated='1' AND active='1' AND
country='" . $_SESSION['Origin'] . "' ORDER BY id ASC";
}

$sql = mysql_query("SELECT * FROM myMembers $queryString");


$centerPages = ""; // Initialize this variable
$sub1 = $pn - 1;
$sub2 = $pn - 2;
$add1 = $pn + 1;
$add2 = $pn + 2;
if ($pn == 1) {
	$centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span>
&nbsp;';
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$add1 . '">' . $add1 . '</a> &nbsp;';
} else if ($pn == $lastPage) {
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$sub1 . '">' . $sub1 . '</a> &nbsp;';
	$centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span>
&nbsp;';
} else if ($pn > 2 && $pn < ($lastPage - 1)) {
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$sub2 . '">' . $sub2 . '</a> &nbsp;';
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$sub1 . '">' . $sub1 . '</a> &nbsp;';
	$centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span>
&nbsp;';
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$add1 . '">' . $add1 . '</a> &nbsp;';
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$add2 . '">' . $add2 . '</a> &nbsp;';
} else if ($pn > 1 && $pn < $lastPage) {
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$sub1 . '">' . $sub1 . '</a> &nbsp;';
	$centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span>
&nbsp;';
	$centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' .
$add1 . '">' . $add1 . '</a> &nbsp;';
}
// This line sets the "LIMIT" range... the 2 values we place to choose
a range of rows from database in our query
$limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage;
// Now we are going to run the same query as above but this time add
$limit onto the end of the SQL syntax
// $sql2 is what we will use to fuel our while loop statement below
$sql2 = mysql_query("SELECT * FROM myMembers $queryString $limit") ;

$paginationDisplay = ""; // Initialize the pagination output variable
// This code runs only if the last page variable is not equal to 1, if
it is only 1 page we require no paginated links to display
if ($lastPage != "1"){
    // This shows the user what page they are on, and the total number
of pages
    $paginationDisplay .= 'Page <strong>' . $pn . '</strong> of ' .
$lastPage. '<img src="images/clearImage.gif" width="48" height="1"
alt="Spacer" />';
	// If we are not on page 1 we can place the Back button
    if ($pn != 1) {
	    $previous = $pn - 1;
		$paginationDisplay .=  '&nbsp;  <a href="' . $_SERVER['PHP_SELF'] .
'?pn=' . $previous . '"> Back</a>';
    }
    // Lay in the clickable numbers display here between the Back and
Next links
    $paginationDisplay .= '<span class="paginationNumbers">' .
$centerPages . '</span>';
    // If we are not on the very last page we can place the Next
button
    if ($pn != $lastPage) {
        $nextPage = $pn + 1;
		$paginationDisplay .=  '&nbsp;  <a href="' . $_SERVER['PHP_SELF'] .
'?pn=' . $nextPage . '"> Next</a><img src="images/clearImage.gif"
width="100" height="1" alt="Spacer" /><a href="' . $Page . '.php">' .
$Page . '</a>';
    }
}

Then I get the data from the database
And put everything on the page:

<FORM name ="form1" method ="post" action ="MembersFrom.php">
<span class="textsize10">

<input name='status' type='radio' id='status' value='1'	<?PHP print
$status_active; ?> />Active Members &nbsp;
<input name='status' type='radio' id='status' value='0' <?PHP print
$status_veteran; ?>/>Veterans&nbsp;&nbsp;</span>
<input name="submit1" type="submit" value="Update" />&nbsp;&nbsp;</
form>
        </h2>
        </td> <td width="30"><?php
		if($paginationDisplay <> "") {
		echo "<a href='PrintMembersFrom.php?myId=$id&myFlag=$Flag'>";}?>
        <img src="images/print.png" width="28" height="28"
border="0"></a></td>
        <td width="43"><?php echo '<img src=images/' .
$_SESSION['Flag'] . ' width="60" height="40" alt=' .
$_SESSION['Origin'] .'>'; ?>
        </td>
    </tr>
</table>

Regards
Marco

[toc] | [next] | [standalone]


#2218

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-06-17 09:02 -0400
Message-ID<itfj94$52n$1@dont-email.me>
In reply to#2216
On 6/17/2011 7:30 AM, Co wrote:
> Hi All,
>
> I have a page which shows all users on our community.
> We have two kinds of users Active members and Veterans.
> I have a radiobutton on my page to switch from Active Members to
> Veterans or vv.
> However when I choose Veterans and have to click to a next page the
> radiobutton gets updated again
> and jumps back to Active Member, so showing the active members again
> in stead of the veterans.
>
<snip>


> Regards
> Marco

As I've told you before - find out what's in your $_POST variable after 
you've submitted the form.

Really - you've got to learn to do your own debugging instead of 
bringing every little problem here.  It doesn't look like you're even 
trying.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#2219

FromCo <vonclausowitz@gmail.com>
Date2011-06-17 06:26 -0700
Message-ID<a4f94d25-1fdd-428f-a733-ff12ea2897c4@j31g2000yqe.googlegroups.com>
In reply to#2218
On 17 jun, 15:02, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 6/17/2011 7:30 AM, Co wrote:> Hi All,
>
> > I have a page which shows all users on our community.
> > We have two kinds of users Active members and Veterans.
> > I have a radiobutton on my page to switch from Active Members to
> > Veterans or vv.
> > However when I choose Veterans and have to click to a next page the
> > radiobutton gets updated again
> > and jumps back to Active Member, so showing the active members again
> > in stead of the veterans.
>
> <snip>
>
> > Regards
> > Marco
>
> As I've told you before - find out what's in your $_POST variable after
> you've submitted the form.
>
> Really - you've got to learn to do your own debugging instead of
> bringing every little problem here.  It doesn't look like you're even
> trying.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

Jerry,

that's what I like about you , you're always so positive.
You really know how to motivate people.
I will try to find what is in the POST variable.

Marco

[toc] | [prev] | [next] | [standalone]


#2220

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-06-17 09:32 -0400
Message-ID<itfl2g$el2$2@dont-email.me>
In reply to#2219
On 6/17/2011 9:26 AM, Co wrote:
> On 17 jun, 15:02, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
>> On 6/17/2011 7:30 AM, Co wrote:>  Hi All,
>>
>>> I have a page which shows all users on our community.
>>> We have two kinds of users Active members and Veterans.
>>> I have a radiobutton on my page to switch from Active Members to
>>> Veterans or vv.
>>> However when I choose Veterans and have to click to a next page the
>>> radiobutton gets updated again
>>> and jumps back to Active Member, so showing the active members again
>>> in stead of the veterans.
>>
>> <snip>
>>
>>> Regards
>>> Marco
>>
>> As I've told you before - find out what's in your $_POST variable after
>> you've submitted the form.
>>
>> Really - you've got to learn to do your own debugging instead of
>> bringing every little problem here.  It doesn't look like you're even
>> trying.
>>
>
> Jerry,
>
> that's what I like about you , you're always so positive.
> You really know how to motivate people.
> I will try to find what is in the POST variable.
>
> Marco

Marco, what you have yet to learn is we are not your unpaid consultants. 
  We are users trying to help each other.

But the key is "help each other".  That means you have to put forth a 
reasonable effort before coming here.

Find out what's in your $_POST variable and use it to trace through your 
code.  That's what the rest of us would have to do.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [next] | [standalone]


#2222

FromCo <vonclausowitz@gmail.com>
Date2011-06-17 09:12 -0700
Message-ID<3fde6b42-40ea-40fa-9e20-0655cb5207be@p13g2000yqh.googlegroups.com>
In reply to#2220
On 17 jun, 15:32, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 6/17/2011 9:26 AM, Co wrote:
>
>
>
>
>
>
>
>
>
> > On 17 jun, 15:02, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
> >> On 6/17/2011 7:30 AM, Co wrote:>  Hi All,
>
> >>> I have a page which shows all users on our community.
> >>> We have two kinds of users Active members and Veterans.
> >>> I have a radiobutton on my page to switch from Active Members to
> >>> Veterans or vv.
> >>> However when I choose Veterans and have to click to a next page the
> >>> radiobutton gets updated again
> >>> and jumps back to Active Member, so showing the active members again
> >>> in stead of the veterans.
>
> >> <snip>
>
> >>> Regards
> >>> Marco
>
> >> As I've told you before - find out what's in your $_POST variable after
> >> you've submitted the form.
>
> >> Really - you've got to learn to do your own debugging instead of
> >> bringing every little problem here.  It doesn't look like you're even
> >> trying.
>
> > Jerry,
>
> > that's what I like about you , you're always so positive.
> > You really know how to motivate people.
> > I will try to find what is in the POST variable.
>
> > Marco
>
> Marco, what you have yet to learn is we are not your unpaid consultants.
>   We are users trying to help each other.
>
> But the key is "help each other".  That means you have to put forth a
> reasonable effort before coming here.
>
> Find out what's in your $_POST variable and use it to trace through your
> code.  That's what the rest of us would have to do.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================

I changed my code a little and created a session.

if(isset($_POST['submit1'])) {
	$_SESSION['status'] = $_POST['status'];
}
if(isset($_SESSION['status'])) {
   $status_account = $_SESSION['status'];
   echo $_SESSION['status'];
   if($status_account=='1') {
		$status_active = 'checked';
		$queryString = "WHERE email_activated='1' AND active='1' AND
country='" . $_SESSION['Origin'] . "' ORDER BY id ASC"; }
    else {
		$status_veteran = 'checked';
		$queryString = "WHERE email_activated='1' AND active='0' AND
country='" . $_SESSION['Origin'] . "' ORDER BY id ASC";
		}

Now the codes first checks if the submit button was clicked.
If so the session gets a value 0 or 1.
So if I am browsing through the pages and the session is set it knows
if it should show active members of veterans.

Only thing I would like to know is how to destroy the session when you
browse away from the page.

Marco

[toc] | [prev] | [next] | [standalone]


#2223

FromJerry Stuckle <jstucklex@attglobal.net>
Date2011-06-17 14:08 -0400
Message-ID<itg582$63g$1@dont-email.me>
In reply to#2222
On 6/17/2011 12:12 PM, Co wrote:
> On 17 jun, 15:32, Jerry Stuckle<jstuck...@attglobal.net>  wrote:
>> On 6/17/2011 9:26 AM, Co wrote:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>> On 17 jun, 15:02, Jerry Stuckle<jstuck...@attglobal.net>    wrote:
>>>> On 6/17/2011 7:30 AM, Co wrote:>    Hi All,
>>
>>>>> I have a page which shows all users on our community.
>>>>> We have two kinds of users Active members and Veterans.
>>>>> I have a radiobutton on my page to switch from Active Members to
>>>>> Veterans or vv.
>>>>> However when I choose Veterans and have to click to a next page the
>>>>> radiobutton gets updated again
>>>>> and jumps back to Active Member, so showing the active members again
>>>>> in stead of the veterans.
>>
>>>> <snip>
>>
>>>>> Regards
>>>>> Marco
>>
>>>> As I've told you before - find out what's in your $_POST variable after
>>>> you've submitted the form.
>>
>>>> Really - you've got to learn to do your own debugging instead of
>>>> bringing every little problem here.  It doesn't look like you're even
>>>> trying.
>>
>>> Jerry,
>>
>>> that's what I like about you , you're always so positive.
>>> You really know how to motivate people.
>>> I will try to find what is in the POST variable.
>>
>>> Marco
>>
>> Marco, what you have yet to learn is we are not your unpaid consultants.
>>    We are users trying to help each other.
>>
>> But the key is "help each other".  That means you have to put forth a
>> reasonable effort before coming here.
>>
>> Find out what's in your $_POST variable and use it to trace through your
>> code.  That's what the rest of us would have to do.
>>
>> --
>> ==================
>> Remove the "x" from my email address
>> Jerry Stuckle
>> JDS Computer Training Corp.
>> jstuck...@attglobal.net
>> ==================
>
> I changed my code a little and created a session.
>
> if(isset($_POST['submit1'])) {
> 	$_SESSION['status'] = $_POST['status'];
> }
> if(isset($_SESSION['status'])) {
>     $status_account = $_SESSION['status'];
>     echo $_SESSION['status'];
>     if($status_account=='1') {
> 		$status_active = 'checked';
> 		$queryString = "WHERE email_activated='1' AND active='1' AND
> country='" . $_SESSION['Origin'] . "' ORDER BY id ASC"; }
>      else {
> 		$status_veteran = 'checked';
> 		$queryString = "WHERE email_activated='1' AND active='0' AND
> country='" . $_SESSION['Origin'] . "' ORDER BY id ASC";
> 		}
>
> Now the codes first checks if the submit button was clicked.
> If so the session gets a value 0 or 1.
> So if I am browsing through the pages and the session is set it knows
> if it should show active members of veterans.
>
> Only thing I would like to know is how to destroy the session when you
> browse away from the page.
>
> Marco

Just like any variable, you can unset($_SESSION['status']).  But there's 
no way to detect if the user leaves this page - only if they load 
another page.

However, if this is only for this page, the $_SESSION variable is 
probably not the way to go.  That's more for keeping track of things 
used on multiple pages such as if the user is logged in and if so, that 
their id is.

But once again, rather than troubleshooting your original problem, 
you're just changing code and hoping it will work.  There were no major 
problems with your other code; you just need to learn to debug it.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web