FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » radio button change after going to next page
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
radio button change after going to next page [message #174545] Fri, 17 June 2011 11:30 Go to previous message
Co is currently offline  Co
Messages: 75
Registered: May 2011
Karma:
Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Displaying UTF-8-encoded strings from MySQL with PHP
Next Topic: User login status?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 08:19:15 GMT 2024

Total time taken to generate the page: 0.19293 seconds