RE: [PHP-DB] displaying records

2002-05-23 Thread matt stewart

at first glance i'd assume that the variable $category is not being passed
through to the second page - you're using it to get the first query, but not
keeping it (either in the url or hiddenform variable for your next page
link).

-Original Message-
From: Natividad Castro [mailto:[EMAIL PROTECTED]]
Sent: 23 May 2002 13:13
To: [EMAIL PROTECTED]
Subject: [PHP-DB] displaying records


Hi to all,
I'm displaying a set of records in different pages.
The user will be able to search by category, let say a user wants to search
projects that belong to 'PHP' category, so I will list all the projects that
belong to that category.
My problem is: the first 10 records on the first page display without any
problem, but when I try to go to the next page it doesn't display any
record.
The weird thing is that if I write my query: SELECT * FROM 150BK WHERE
CATEGORY='PHP', I don't any problem I can see all my record and go through
from page to page. But when I write my query requesting the name from the
drop down menu from the search page I get just the first 10 records.
For example, SELECT * FROM 150BK WHERE CATEGORY='$category' //here is where
the problem

Any help is greatly appreciate
Thanks in advanced
Nato

here is my code



Record Set Paging with Page Navigation



PHP/MySQL Record Set Paging with Page Navigation
 0) {
   $sql .= " LIMIT $offset, $pagesize ";   // Get record set = pagesize
every time
   $result = mysql_query($sql);
   if ($absolutepage == 1) {
$pag1 = $absolutepage;
   } else {
$pag1 = (($absolutepage - 1) * $pagesize) + 1;
   }
   $pag2 = $pag1 + ($pagesize - 1);
   if ($pag2 > $recordcount)
$pag2 = $recordcount;
   echo "";
   echo "Displaying records $pag1 to $pag2 (of " . $recordcount.")";
   PagNav($pagesize, $pagecount, $absolutepage, $recordcount, $sql, $url) ;
   echo "";
   $fields = mysql_num_fields($result);
 for ($i=0; $i < $pagesize; $i++) {
 while($query_data = mysql_fetch_array($result))
 {
 $id = $query_data[ID];
 $name = $query_data[NAME];
  echo $id. " | ".$name. " " . "read
more..." . "" . "";
  echo "";
  }
   echo "\n";
   }

   } else {
   echo "No records found.";
}
echo "";


function PagNav($pagesize, $pagecount, $absolutepage, $recordcount, $sql,
$url)
{
global $sql, $url, $pagesize, $pagecount, $absolutepage, $recordcount;
$pad="" ;
$maxpages = $pagecount ;
if ( ($absolutepage % 10) == 0) {
   $counterstart =  $absolutepage - 9 ;
} else {
   $counterstart = $absolutepage - ($absolutepage % 10) + 1 ;
}
$counterend = $counterstart + 9 ;
echo "Page ".$absolutepage." of ".$pagecount.": ";
if ($counterend > $maxpages) $counterend = $maxpages ;
if ($counterstart != 1) {
   $ref = "First | " ;
   echo $ref ;
   $ref = "Prev 10 Pages " ;
   echo $ref ;
}
echo "[ " ;
for ($counter = $counterstart; $counter < $counterend +1;$counter++ ) {
if ($counter >= 10) $pad="" ;
if (! ($counter == $absolutepage)) {
   $ref = "" . $pad . $counter . "" ;
} else {
   $ref = "" . $pad . $counter . "" ;
}
echo $ref ;
if (!($counter == $counterend)) print " " ;
}
echo " ]" ;
if ($counterend != $maxpages) {
$ref = " Next 10 Pages" ;
echo $ref ;
$ref = " | Last" ;
echo $ref ;
}
echo "";
}
?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] displaying records

2002-05-23 Thread Natividad Castro

Hi to all,
I'm displaying a set of records in different pages.
The user will be able to search by category, let say a user wants to search
projects that belong to 'PHP' category, so I will list all the projects that
belong to that category.
My problem is: the first 10 records on the first page display without any
problem, but when I try to go to the next page it doesn't display any
record.
The weird thing is that if I write my query: SELECT * FROM 150BK WHERE
CATEGORY='PHP', I don't any problem I can see all my record and go through
from page to page. But when I write my query requesting the name from the
drop down menu from the search page I get just the first 10 records.
For example, SELECT * FROM 150BK WHERE CATEGORY='$category' //here is where
the problem

Any help is greatly appreciate
Thanks in advanced
Nato

here is my code



Record Set Paging with Page Navigation



PHP/MySQL Record Set Paging with Page Navigation
 0) {
   $sql .= " LIMIT $offset, $pagesize ";   // Get record set = pagesize
every time
   $result = mysql_query($sql);
   if ($absolutepage == 1) {
$pag1 = $absolutepage;
   } else {
$pag1 = (($absolutepage - 1) * $pagesize) + 1;
   }
   $pag2 = $pag1 + ($pagesize - 1);
   if ($pag2 > $recordcount)
$pag2 = $recordcount;
   echo "";
   echo "Displaying records $pag1 to $pag2 (of " . $recordcount.")";
   PagNav($pagesize, $pagecount, $absolutepage, $recordcount, $sql, $url) ;
   echo "";
   $fields = mysql_num_fields($result);
 for ($i=0; $i < $pagesize; $i++) {
 while($query_data = mysql_fetch_array($result))
 {
 $id = $query_data[ID];
 $name = $query_data[NAME];
  echo $id. " | ".$name. " " . "read
more..." . "" . "";
  echo "";
  }
   echo "\n";
   }

   } else {
   echo "No records found.";
}
echo "";


function PagNav($pagesize, $pagecount, $absolutepage, $recordcount, $sql,
$url)
{
global $sql, $url, $pagesize, $pagecount, $absolutepage, $recordcount;
$pad="" ;
$maxpages = $pagecount ;
if ( ($absolutepage % 10) == 0) {
   $counterstart =  $absolutepage - 9 ;
} else {
   $counterstart = $absolutepage - ($absolutepage % 10) + 1 ;
}
$counterend = $counterstart + 9 ;
echo "Page ".$absolutepage." of ".$pagecount.": ";
if ($counterend > $maxpages) $counterend = $maxpages ;
if ($counterstart != 1) {
   $ref = "First | " ;
   echo $ref ;
   $ref = "Prev 10 Pages " ;
   echo $ref ;
}
echo "[ " ;
for ($counter = $counterstart; $counter < $counterend +1;$counter++ ) {
if ($counter >= 10) $pad="" ;
if (! ($counter == $absolutepage)) {
   $ref = "" . $pad . $counter . "" ;
} else {
   $ref = "" . $pad . $counter . "" ;
}
echo $ref ;
if (!($counter == $counterend)) print " " ;
}
echo " ]" ;
if ($counterend != $maxpages) {
$ref = " Next 10 Pages" ;
echo $ref ;
$ref = " | Last" ;
echo $ref ;
}
echo "";
}
?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php