Hello
I have searched and tried to implement this without any success. I have written a code to update several records using a checkbox. This works perfectly. However, I wanmt to add the pagination functionality to it, but this is proving a nightmare. Please can some one help me?
Below is the code
<?php
// include needed files
require('../db_config.php');
require('../global.php');
require("../lib/Pager.class.php");
// connect to the database
db_connect($mysql['username'], $mysql['password'], $mysql['database'],$mysql['host']);
// assign config options from database to an array
$config = get_config($mysql['prefix']);
debug_mode($config['debug_mode']);
// start the session
admin_sessions($config['admin_session_expire']);
if (!isset($_SESSION['logged_in']))
{
redirect('./login.php');
}
// start class
$p = new Pager;
// results per page
$limit = 30;
// gert member type description
if(isset($_GET['description']))
{
$memberType = $_GET['memberType'];
}
$sql1="select id from members_memberType where description = '".$_GET['memberType']."'" ;
$result=mysql_query($sql1);
$row = mysql_fetch_array($result);
$memberTypeId = $row['id'];
if(isset($_POST['checkbox'])){$checkbox = $_POST['checkbox'];
if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])
$id = "('" . implode( "','", $checkbox ) . "');" ;
$sql="UPDATE members_users SET memberTypeid = ".$memberTypeId." WHERE id in $id" ;
$result = mysql_query($sql) or die(mysql_error());
}
$sql="SELECT * FROM vwUserMemberType where memberTypeId = $memberTypeId or memberTypeId < 2 order by memberTypeId desc ";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
// this is the search function, where the administrator will be able to search
// for users to be added to this member type
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Manager Users</title>
<link href="../images/admin.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript" src="../images/hint.js">
<!--
function un_check(){
for (var i = 0; i < document.frmactive.elements.length; i++) {
var e = document.frmactive.elements[i];
if ((e.name != 'allbox') && (e.type == 'checkbox')) {
e.checked = document.frmactive.allbox.checked;
}
}
}
//-->
</script>
<link href="../images/admin.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<table width="649" align="center" border="0" cellspacing="1" cellpadding="0">
<tr>
<td width="329" height="58"><img src="../images/header_logo.gif" align="center" width="252" height="58" border="0" /></a></td>
</tr>
<tr>
<td height="2" colspan="2"><img src="../images/grey_pixel.gif" width="100%" height="2" /></td>
</tr>
<tr>
<td height="20" colspan="2"><strong><a href="./index.php" class="style2">Return to Admin Panel</a> </strong></td>
</tr>
<tr>
<td height="20" colspan="2"><strong><a href="./membershiptypelist.php" class="style2">Return to Manage Membership Types</a> </strong></td>
</tr>
<tr>
<td height="18"></td>
</tr>
<tr>
<td><form name="frmactive" method="post" action="">
<table valign="bottom" align="center" width="60%" border="0" cellpadding="3" cellspacing="1">
<tr>
<td align="center" width="60%" class="style5">Member Type:</td><td><input name="memberType" maxlength="15" type="label" readonly="readonly" id="memberType" value="<? echo '' . $_GET['memberType'] . ''; ?>" /></td>
</tr>
<tr height="40">
<td>
</td>
</tr>
<tr>
<td colspan="8" align="center" class="style5"><strong>Assign Members to Member Type</strong> </td>
</tr>
</tr>
<table width="100%" border="1" align="right">
<tr><td>
<table width="100%" border="0" align="center">
<tr>
<td align="center" class="style2"><strong>Username</strong></td>
<td align="center" class="style2"><strong>Firstname</strong></td>
<td align="center" class="style2"><strong>Lastname</strong></td>
<td align="center" class="style2"><strong>Current House Group</strong></td>
<td align="center" width="55%" class="style5">Add to <?echo ''. $_GET['memberType'].''; ?></td>
</tr>
<td height="18"></td>
<?php
while($rows=mysql_fetch_array($result)){
$idNotThisMemType = $rows['id'];
?>
<tr>
<td align="center" width="17%" class="style2"><? echo $rows['username']; ?></td>
<td align="center" width="17%" class="style2"><? echo $rows['firstname']; ?></td>
<td align="center" width="17%" class="style2"><? echo $rows['lastname']; ?></td>
<td align="center" width="27%" class="style2"><? echo $rows['description']; ?></td>
<td align="center" width="22%" class="style2"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
</tr>
<?php
}
?>
<table height="20">
<tr>
<td>
</td>
</tr>
</table>
</table>
</table>
<table align="right" width="50%">
<tr align="right">
<td align="center"><input name="activate" type="submit" id="activate" value="Assign to <? echo '' . $_GET['memberType'] . ''; ?>"</td>
</tr>
</table>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>