kat32 Posted August 25, 2009 Share Posted August 25, 2009 When I click the submit button, I want to display the values of the checkbox that I checked in all pages. How do I modify this to work to remember what was checked on all pages.. Thanks <?php session_start(); include 'dbconnect.php'; $_SESSION['checked_uid'] = array(); if($_POST['submit']){ $checkedboxes = ''; foreach($_POST['cbox'] as $checkedid){ $checkedboxes .= $checkedid.','; } //$_SESSION['checked_uid'] = implode(rtrim($checkedboxes,',')); $_SESSION['checked_uid'] = substr($checkedboxes, 0, strlen( $checkedboxes ) - 1 ); } if(isset($_GET['p'])){ if($_GET['p']) $page = $_GET['p']; } else $page = 1; $q = mysql_query("SELECT * FROM tblusers"); $rows = mysql_num_rows($q); $posts_per_page=20; $pages = ceil($rows / $posts_per_page); $offset = $page * $posts_per_page - $posts_per_page;?> <form method="post" name="frm1" action="<? echo $_SERVER['PHP_SELF'];?>"><?php $query = mysql_query("SELECT * FROM tblusers LIMIT $posts_per_page OFFSET $offset") or die(mysql_error()); while($d = mysql_fetch_object($query)){ $uid=$d->uid; $username=$d->username; $checked = (in_array($uid,$_SESSION['checked_uid'])) ? 1 : 0; echo $username.' '; ?> <input type="checkbox" name="cbox[]" value="<?php echo $uid; ?>" <?php echo $checked ? 'checked' : '' ?> > <br /><?php } if($page > 1 ){ echo 'Pages:'; } if($page > 1) echo '<a href="?p=' . ($page - 1) . '"></a> '; else echo ''; for($a = 1; $a <= $pages; $a++) if($a == $page) echo "$a "; else echo '<a href="?p=' . $a . '">' . $a . '</a> '; if($page < $pages) echo '<a href="?p=' . ($page + 1) . '"></a>'; else echo ''; echo '</p>'; ?> <input type="submit" name="submit"></form> Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/ Share on other sites More sharing options...
merck_delmoro Posted August 25, 2009 Share Posted August 25, 2009 post your check value in every page and place it into the session Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/#findComment-906239 Share on other sites More sharing options...
kat32 Posted August 27, 2009 Author Share Posted August 27, 2009 post your check value in every page and place it into the session how will I post the checkbox values if the previous and next are links(not buttons)? Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/#findComment-907194 Share on other sites More sharing options...
Rommeo Posted August 27, 2009 Share Posted August 27, 2009 can you make it more clear you mean.. Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/#findComment-907199 Share on other sites More sharing options...
merck_delmoro Posted August 27, 2009 Share Posted August 27, 2009 use $_POST to sends the check values in every page and make a $_SESSION for them Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/#findComment-907311 Share on other sites More sharing options...
kat32 Posted August 27, 2009 Author Share Posted August 27, 2009 how will I get values of checkbox if the previous and next are links(not buttons)? Link to comment https://forums.phpfreaks.com/topic/171868-display-the-values-of-the-checkbox/#findComment-907917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.