Skip to main content
Inspiring
December 17, 2010
Answered

Recordset paging by A,B,C....instead of Next Page, Prev Page, etc.?

  • December 17, 2010
  • 1 reply
  • 6257 views

Hello geniuses,

I was wondering if there is a way to do the following:

I currently have a member database (MySQL) that I manage for a client. Using DW CS4, I used the built-in Recordset paging to add a navigation bar to the top of the member listing, limiting it to 50 per page. Since there are so many members in this organization, my client has asked me to create an A,B,C...navigation bar, rather than First Page - Next Page - Prev Page - Last Page. Is there a way to do this? Note that if a member is added or dropped from the list and they happen to be the first of the B's (for example), then the marker has to move accordingly. Thanks for pointing me in the right direction.

Regards,

Gail

This topic has been closed for replies.
Correct answer Günter_Schenk

First, you were correct about the missing single quotes, and that solved

the problem. Thanks very much.

So, a feature it is! I guess there's no real harm done to load more at

the "first look" of the member list. It does work correctly for all

letters. You are right in that if I drop "maxusers" down to 10 or 20,

the bottom half of, say, the Bs, gets cut off.

I originally had the Recordset Paging Navigation Bar on my page, but my

client didn't like it because he had to page through and hunt for

members. Hence my determination to provide an A,B,C navigation for him,

which you have so kindly helped me with. I didn't think about using both

features - the paging navigation bar, plus the A,B,C navigation. That

would definitely solve the worry of someday going over 50 members in any

given letter and not noticing that the list is cut off. I'll add it back.

I want to thank you profusely for all your help on this. Not only have

you stuck with me, but your timely responses meant I could finish this

today. You are my new best friend!

Best regards,

Gail


Gail,

it´s been a real pleasure to participate in such an intense "dialogue", and I salute you for remaining persistent !

Cheers,

Günter

1 reply

December 17, 2010

By A,B,C... do you mean that clicking on A will only show memebers whose name starts with A or do you mean like 1,2,3...10 etc where clicking on 1 will show the first 50 people that were entered into the DB? Please specify.

You can find useful information by searching for:

(your unmentioned server side scripting language) pagination

Inspiring
December 17, 2010

I mean that clicking on A will only display those whose last names

start with A. Sorry for any confusion.

Gail

Inspiring
March 28, 2011

So here is a working "filter lastname by initial letter " solution which will can be nicely integrated into Dreamweaver´s PHP Recordset Paging and will (of course) not affect the number of recordsets which are displayed on first page load.

This time I´m not going to provide some ready-made code for everyone to copy & paste -- nope, this time I´ll be an unkind chap and attach several screenshots of fthe code (step1, step 2, step 3) in order to make interested readers reproduce the steps the hard way, as every serious coder should

Have fun !

Günter


Gunter,

Finally getting back to this; sorry for the delay. I'm thinking I have some of the code in the wrong place, as it's not displaying correctly. Here is my salient code:

------------------

// dynamic where clause: letter

if(!empty($_GET['letter']) && ctype_alpha($_GET['letter']))
{
    $whereclause = " AND lastname LIKE '".$_GET[letter]."%'";
}
else {
    $whereclause = "";
}

//END

$maxRows_listUsers = 50;
$pageNum_listUsers = 0;
if (isset($_GET['pageNum_listUsers'])) {
  $pageNum_listUsers = $_GET['pageNum_listUsers'];
}
$startRow_listUsers = $pageNum_listUsers * $maxRows_listUsers;

mysql_select_db($database_GCSMembership, $GCSMembership);
$query_listUsers = "SELECT user_id, lastname, firstname, email FROM users WHERE activity_status = 'y' ORDER BY lastname ASC";
$query_limit_listUsers = sprintf("%s LIMIT %d, %d", $query_listUsers, $startRow_listUsers, $maxRows_listUsers);
$listUsers = mysql_query($query_limit_listUsers, $GCSMembership) or die(mysql_error());
$row_listUsers = mysql_fetch_assoc($listUsers);

if (isset($_GET['totalRows_listUsers'])) {
  $totalRows_listUsers = $_GET['totalRows_listUsers'];
} else {
  $all_listUsers = mysql_query($query_listUsers);
  $totalRows_listUsers = mysql_num_rows($all_listUsers);
}
$totalPages_listUsers = ceil($totalRows_listUsers/$maxRows_listUsers)-1;

---------------

You stated to put the dynamic whereclause 'above' my document's main recordset. I think I've done this (I put it above my $query_listUsers statement). Should it be incorporated into the query itself instead? Also I'm not sure, if it's in the correct position, where I incorporate my existing whereclause  (WHERE activity_status = 'y'). Is it in this statement: else { $whereclause = "";  In other words should it be AND { $whereclause = activity_status = 'y'; ? AND is the critical delimiter I believe. This is the most important filter as it filters out lapsed members, etc. Another question: do I need the code  ORDER BY lastname ASC"? I'm assuming I still need to keep this, as I want, within each letter, for them to be in alphabetical order.

Another question: do I get rid of the $query_limit_listUsers statement? Because as of now, the page is still just displaying the first 50 members.

The easy part was creating the links for A,B,C. These are displaying correctly except they are run together (no space separating each letter, and I believe this means the links aren't separated either. However I can't test this until I get the A,B,C segregated display of member names working properly.

Thanks for all your help and patience,

Gail