PDA

View Full Version : Problem with paging options


neogine
03-28-2011, 07:45 AM
Hi,

i m new with php programming... I m working on one form in which i have created filter options for filter dynamic table content by completed, approve and rejected status....

but problem is when i m selecting any filtered option using select list data is displayed... but when i m clicking on next button in paging... dynamic table showing blank... same slect list getting blank.... anyone will help me...?

edbr
03-28-2011, 08:06 AM
what code are you using to page results?

neogine
03-28-2011, 08:13 AM
Thank You for reply....

You can download file from here.

http://www.4shared.com/file/Gq_MfWA5/brakedown1.html

i m using most spry framework functions of Dreamweaver. same using spry paging controls.

thank you

neogine
03-28-2011, 08:35 AM
code of php file

<?php require_once('../Connections/localhost.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "client";
$MM_donotCheckaccess = "false";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}

$MM_restrictGoTo = "../index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_Recordset1 = 30;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$myID = $_SESSION['MM_Username'];


$mystatus=$_GET['status'];
switch ($options)
{
case "All";
$All="selected";
break;
case "Completed";
$Completed="selected";
break;
case"Rejected";
$Rejected="selected";
break;
case"Pending";
$Pending="selected";
break;
}
$mystatus=$_POST['status'];
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

//databse queary for filters
$query_Recordset1 = "SELECT username, Jobid, Market, General_10, Entry_Points, Dept_Points, General_Points, Total_Points FROM form_gf ";
if($mystatus !=='All'){
$query_Recordset1 .= "WHERE status = '$mystatus'";}
else {
$query_Recordset1 .= "ORDER BY form_gf.Jobid";}


mysql_select_db($database_localhost, $localhost);

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

mysql_select_db($database_localhost, $localhost);
$query_status = "SELECT dropdown.options FROM dropdown WHERE dropdown.dropdownname = 'status'";
$status = mysql_query($query_status, $localhost) or die(mysql_error());
$row_status = mysql_fetch_assoc($status);
$totalRows_status = mysql_num_rows($status);mysql_select_db($database_ localhost, $localhost);
$query_status = "SELECT options FROM dropdown WHERE dropdownname = 'status' ORDER BY options ASC";
$status = mysql_query($query_status, $localhost) or die(mysql_error());
$row_status = mysql_fetch_assoc($status);
$totalRows_status = mysql_num_rows($status);

$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_Recordset1") == false &&
stristr($param, "totalRows_Recordset1") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
?>
<!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=utf-8" />
<title>Brakedown Report</title>
<link href="../template.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Menu/js/jquery.js"></script>
<script type="text/javascript" src="../Menu/js/interface.js"></script>
<script type="text/javascript" src="../Menu/js/fisheye_patched.js"></script>
<!--[if lt IE 7]>
<style type="text/css">
.dock img { behavior: url(iepngfix.htc) }
</style>
<![endif]-->

<link href="../Menu/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.Header { font-family: "Segoe UI";
font-size: 12px;
font-weight: 500;
color: #CCC;}

.table {
font-family: "Segoe UI";
font-size: 10pt;
border: 1px solid #000;
}
.text {
font-family: "Segoe UI";
font-size: 10pt;
}
a {
font-family: "Segoe UI";
font-size: 12px;
color: #333;
font-weight: bold;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #333;
}
a:hover {
text-decoration: none;
color: #36F;
}
a:active {
text-decoration: none;
color: #333;
}
</style>
</head>

<body>
<!--Wrapper Start-->
<div id="wrapper">
<!--Header Start-->

<div id="header">
<div id="logo"><img src="../images/logo.png" alt="isnlogo" width="64" height="30" align="middle" longdesc="http://www.isngs.com" /></div>
<div id="userinfo">
<table width="180" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="27" height="34"><img src="../images/user.png" width="26" height="30" alt="user" /></td>
<td width="77">Sagar Dhande</td>
<td width="26"><img src="../images/arrow.png" width="26" height="30" alt="arrow" /></td>
</tr>
</table>
</div>
<div id="status"></div>
</div>

<!--Header end-->
<div id="content">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr align="center">
<td width="99%"> <div id="dash3">
<div id="dash3_grid_head">Total Reccords&nbsp;&nbsp;&nbsp;&nbsp;</div>
<div id="dash3_grid_cont_back"><br />
<table width="890" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
<tr class="Header"><form action="" method="post">
<td height="55" colspan="3" align="center" valign="middle" id="filters">Filter By Status</td>
<td align="left" valign="middle"><select name="status" id="status2" onchange="document.forms[0].submit();">
<option value="" <?php if (!(strcmp("", $mystatus))) {echo "selected=\"selected\"";} ?>></option>
<?php
do {
?>
<option value="<?php echo $row_status['options']?>"<?php if (!(strcmp($row_status['options'], $mystatus))) {echo "selected=\"selected\"";} ?>><?php echo $row_status['options']?></option>
<?php
} while ($row_status = mysql_fetch_assoc($status));
$rows = mysql_num_rows($status);
if($rows > 0) {
mysql_data_seek($status, 0);
$row_status = mysql_fetch_assoc($status);
}
?>
</select></td>
<td align="left" valign="bottom"><a href="excel.php"></a></td>
<td align="left" valign="bottom">&nbsp;</td>
<td align="center" valign="middle"><a href="../excelexprt.php"></a></td>
<td align="center" valign="middle">&nbsp;</td>
<td align="center" valign="middle">&nbsp;</td>
<td align="right" valign="middle"><a href="excel.php"><img src="../images/Export.png" alt="Export" width="48" height="48" border="0" /></a></td>
</form> </tr>
<tr class="Header">
<td height="2" colspan="10" align="center" valign="bottom" id="filters3"><hr color="#333333" size="1px"/></td>
</tr>
<tr class="Header">
<td height="345" colspan="10" align="center" valign="bottom" id="filters"><a href="../excelexprt.php">
<iframe src="pai1.php" width="485px" height="370px" frameborder="0"></iframe>
</a></td>

</tr>
<tr class="Header">
<td height="22" colspan="3" align="center" valign="bottom" id="filters2">&nbsp;</td>
<td align="left" valign="bottom">&nbsp;</td>
<td align="left" valign="bottom">&nbsp;</td>
<td align="left" valign="bottom">&nbsp;</td>
<td colspan="4" align="center" valign="middle">&nbsp;</td>
</tr>
<tr class="Header">
<td style="border: 1px solid #000;" height="44" colspan="3" align="center" valign="middle" bgcolor="#666666">Options</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666" class="Header">Job ID</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Market ID</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Transaction No.</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Entry Points</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Department Points</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">General Points</td>
<td style="border: 1px solid #000;" width="100" align="center" valign="middle" bgcolor="#666666">Total Points</td>
</tr>

<?php do { ?> <tr>
<td width="31" height="28" align="center" style="border: 1px solid #000;"><a href="../pdf.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/pdf.png" alt="PDF Export" width="16" height="16" border="0" /></a></td>
<td width="31" style="border: 1px solid #000;" align="center"><a href="../view.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/preview.png" alt="Preview" width="16" height="16" border="0" /></a></td>
<td width="31" style="border: 1px solid #000;" align="center"><a href="../update_form.php?Jobid=<?php echo $row_Recordset1['Jobid']; ?>" target="_blank"><img src="../images/Edit.png" alt="Edit" width="16" height="16" border="0" /></a></td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Jobid']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Market']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['General_10']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Entry_Points']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Dept_Points']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['General_Points']; ?>&nbsp;&nbsp;</td>
<td style="border: 1px solid #000;" align="right"><?php echo $row_Recordset1['Total_Points']; ?>&nbsp;&nbsp;</td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>


<table border="0" align="center" width="270px">
<tr>
<td width="30px" valign="middle"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>"><img src="../images/first.png" alt="First" width="16" height="16" alt="First Page" />&nbsp;</a>
<?php } // Show if not first page ?></td>
<td width="30px" valign="middle"><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="../images/previous.png" alt="Previous Page" width="16" height="16" alt="previous" />&nbsp;</a>
<?php } // Show if not first page ?></td>
<td width="150px" style="font-family:'Segoe UI'; font-size:12px; color:#333; font-weight:700; line-height:40px;"> Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?></td>
<td width="30px" valign="middle"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="../images/Next.png" width="16" height="16" alt="Next" />&nbsp;</a>
<?php } // Show if not last page ?></td>
<td width="30px" valign="middle"><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="../images/Last.png" alt="Last Page" width="16" height="16" alt="Last" />&nbsp;</a>
<?php } // Show if not last page ?></td>
</tr>
</table>
</table>
</div>
<div id="dash3_grid_bot"></div>
</div><br />
<br />
<br />
</td>
</tr>
</table>

<div id="dashboard">


</div>
</div>

<div class="dock" id="dock2">
<div class="dock-container2">
<a class="dock-item2" href="client.php"><span>Dashboard</span><img src="../Menu/images/Dashboard-.png" alt="home" /></a>
<a class="dock-item2" href="brakedown.php"><span>Brakedown Report</span><img src="../Menu/images/brakedown.png" alt="contact" /></a>
<a class="dock-item2" href="Compliance.php"><span>Compliance Report</span><img src="../Menu/images/compliance.png" alt="portfolio" /></a>
<a class="dock-item2" href="jobstatus.php"><span>Job Status Report</span><img src="../Menu/images/jobstatus.png" alt="music" /></a>
<a class="dock-item2" href="reports.php"><span>Reports</span><img src="../Menu/images/charts.png" alt="video" /></a>
<a class="dock-item2" href="#"><span>Logout</span><img src="../Menu/images/off.png" alt="history" /></a>
</div>
</div>
<!--Menu End-->
</div>
<!--Wrapper End-->
<!--dock menu JS options -->
<script type="text/javascript">

$(document).ready(
function()
{
$('#dock2').Fisheye(
{
maxWidth: 60,
items: 'a',
itemsText: 'span',
container: '.dock-container2',
itemWidth: 40,
proximity: 80,
alignment : 'left',
valign: 'bottom',
halign : 'center'
}
)
}
);

</script>
</body>
</html>
<?php
mysql_free_result($Recordset1);
mysql_free_result($status);
?>

neogine
03-28-2011, 08:55 AM
Hi,

Please suggest me any other way if there no option...

thank you

neogine
03-28-2011, 10:36 AM
some one please help me

Corrosive
03-28-2011, 11:27 AM
Hate to say this but you might be better off asking this on a dedicated PHP forum such as; http://www.phpfreaks.com/forums/index.php because this forum tends to be mainly noobs who want to use DW to build static sites. Apart from Ed and DJ there aren't really any PHP experts here.

edbr
03-29-2011, 01:53 AM
expert?? as in i once was pert but am no more perhaps.
i seem to recall this is a point where the dw wizard drops its wand. your best option is to use a paging class frankly IMO, it will need a little implementnig but will certainly do the job, ill have a rummage and see what i can find

edbr
03-29-2011, 02:53 AM
ok try this one. save the below as paging.php
<?php


class paging
{
var $conn;
var $p;
var $page;
var $q;
var $query;
var $next;
var $prev;
var $number;

function paging($line=5, $step=5, $prev="[prev]", $next="[next]", $number="[%%number%%]")
{
$this->next=$next;
$this->prev=$prev;
$this->number=$number;
$this->p["line"]=$line;
$this->p["step"]=$step;
$_SERVER["QUERY_STRING"]=preg_replace("/&page=[0-9]*/","",$_SERVER["QUERY_STRING"]);
if (empty($_GET["page"])) {
$this->page=1;
} else {
$this->page=$_GET["page"];
}
}

function db($host,$username,$password,$dbname)
{
$this->conn=mysql_pconnect($host, $username, $password) or die("Connection Error");
mysql_select_db($dbname);
return $this->conn;
}

function query($query)
{
$kondisi=false;
// only select
if (!preg_match("/^[\s]*select*/i",$query)) {
$query="select ".$query;
}

$querytemp = mysql_query($query);
$this->p["count"]= mysql_num_rows($querytemp);

// total page
$this->p["total_page"]=ceil($this->p["count"]/$this->p["line"]);

// filter page
if ($this->page<=1)
$this->page=1;
elseif ($this->page>$this->p["total_page"])
$this->page=$this->p["total_page"];


$this->p["start"]=$this->page*$this->p["line"]-$this->p["line"];

$query=$query." limit ".$this->p["start"].",".$this->p["line"];

$query=mysql_query($query) or die("Query Error");
$this->query=$query;
}

function result()
{
return $result=mysql_fetch_object($this->query);
}

function result_assoc()
{
return mysql_fetch_assoc($this->query);
}

function print_no()
{
$number=$this->p["start"]+="";
// return $number;
}

function print_color($color1,$color2)
{
if (empty($this->p["count_color"]))
$this->p["count_color"] = 0;
if ( $this->p["count_color"]++ % 2 == 0 ) {
return $color=$color1;
} else {
return $color=$color2;
}
}

function print_info()
{
$page=array();
$page["start"]=$this->p["start"]+1;
$page["end"]=$this->p["start"]+$this->p["line"];
$page["total"]=$this->p["count"];
$page["total_pages"]=$this->p["total_page"];
if ($page["end"] > $page["total"]) {
$page["end"]=$page["total"];
}
if (empty($this->p["count"])) {
$page["start"]=0;
}

return $page;
}

function print_link()
{
//generate template
function number($i,$number)
{
return ereg_replace("^(.*)%%number%%(.*)$","\\1$i\\2",$number);
}
$print_link = false;

if ($this->p["count"]>$this->p["line"]) {

// print prev
if ($this->page>1)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page-1)."\">".$this->prev."</a>\n";

// set number
$this->p["below"]=$this->page-$this->p["step"];
if ($this->p["below"]<1) $this->p["below"]=1;

$this->p["above"]=$this->page+$this->p["step"];
if ($this->p["above"]>$this->p["total_page"]) $this->p["above"]=$this->p["total_page"];

// print start
if ($this->page<>1)
{
for ($i=$this->p["below"];$i<=$this->page-1;$i++)
$print_link .="<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";
}
// print active
if ($this->p["total_page"]>1)
$print_link .= "<b>".number($this->page,$this->number)."</b>\n";

// print end
for ($i=$this->page+1;$i<=$this->p["above"];$i++)
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=$i\">".number($i,$this->number)."</a>\n";

// print next
if ($this->page<$this->p["total_page"])
$print_link .= "<a href=\"".$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"]."&page=".($this->page+1)."\">".$this->next."</a>\n";

return $print_link;
}
}
}
?>



now to use this you must modify some values.

edbr
03-29-2011, 03:01 AM
from your page this will call the class

<?php

require("paging.php");

// define $cat to method of determining filter
$cat= $_GET['value'];


// number of results per page
$paging=new paging(20,5);


//edit your connection details
$paging->db("localhost","username","password","database");

// edit your tablename Table and field

$paging->query("Select * FROM table where field = '$cat'");

$page=$paging->print_info();
echo " $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]\n <hr>";



while ($result=$paging->result_assoc()) {

// edit field names
$first=$result['first'];
$second=$result['second'];
$third=$result['third'];
?>



<?php echo $first ; ?>

<?php echo $second ;?>

<?php echo $third. "<br>" ; }?>




<?php echo "<hr>".$paging->print_link();?>



follow the comments. i have echoed 3 values each in its own code block so you can easily use a table in html