generating a page number based on recordcount

Hi guys, im trying to generate a page number based on  the db count below but cant seem to get it to work,

Perhaps someone can shed some light or point me in the right direction. ive used my subscription_id number 341 as an example.

my outpout of the script below should be subscription_tracking.php?page='page number here'&sID='341'&action=edit

however i just get, subscription_tracking.php?page=&sID='341'&action=edit

let me walk through what Im doing here.

<?php
// lets do a simple query of my subscriptions table
$subscrib_query_raw = "select * from " . TABLE_SUBSCRIPTIONS .  " order by s.subscription_id";

//my goal is to generate a page number because im linking ot a customer record on a diffrent page, and I paginate this page so I only see 20 rows per page.
//because of this if I select a customer record that has a subscription id number of 341, it isnt going ot be on the first page, so i need to generate the page number for the link

// Split Page
// reset page when page is unknown
if ($_GET['pagesubpage'] == '' and $_GET['sID'] != '') {

/count the records  
  $check_page = $db->Execute($subscrib_query_raw);
  $check_count=1;
  if ($check_page->RecordCount() > '20') {
    while (!$check_page->EOF) {
      if ($customers->fields['subscription_id'] == $_GET['sID']) {
        break;
      }
      $check_count++;
      $check_page->MoveNext();
    }
// now that ive counted my records, I can generate a page number by doing some math
    $_GET['pagesubpage'] = round((($check_count/'20')+(fmod($check_count,'20') !=0 ? .5 : 0)),0);
 
// and default to 1 if fails
} else {
    $_GET['pagesubpage'] = 1;
  }
}

//im generating a simple report of rows based on a query earlier in my code on the same page.
  while (!$customers->EOF) {

    if ($customer_id == $customers->fields['subscription_id'] && substr($action, 0, 3) != 'new') {
        $cInfo = new objectInfo($customers->fields);
    }
   
//no im going to generate my links so that when i click on this row, it will take me to the subscriptions page where i can view the subscription record.

 if (isset($cInfo) && is_object($cInfo) && ($customers->fields['subscription_id'] == $cInfo->subscription_id)) {                                                                                                                                                                                                                                                            
        echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SUBSCRIPTION_TRACK_ADM, 'page=' . $_GET['pagesubpage'] . '&sID=' . $customers->fields['subscription_id'] . '&action=edit', 'NONSSL') . '\'">' . "\n";
    } else {                                                                                                                                                                                                                     //zen_href_link(FILENAME_SUBSCRIPTION_TRACK_ADM, . (isset($_GET['page']) ? '&page=' . $_GET['page'] : ''), 'NONSSL'));
      echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_SUBSCRIPTION_TRACK_ADM, 'page=' . $_GET['pagesubpage'] . '&sID=' . $customers->fields['subscription_id'] . '&action=edit', 'NONSSL') . '\'">' . "\n";
    }
 
?>

// it looks good, but its not working. anyone out there that can walk me through, and lend a guiding hand.
redcableAsked:
Who is Participating?
 
ShelfieldCollegeCommented:
on your url line you're using the variable name of page and in your if statement your using $_GET['pagesubpage'] which doesn't appear to have been set anywhere, unless I'm looking in the wrong place.

Cheers

/Matt
0
 
peyoxCommented:
Look at first IF:

if ($_GET['pagesubpage'] == '' and $_GET['sID'] != '')

I think your program is not getting into this IF which results in empty $_GET['pagesubpage'] value.
0
 
redcableAuthor Commented:
any reason why that you can think of mate?
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
JKlatteCommented:
Either change your url to:

subscription_tracking.php?pagesubpage='page number here'&sID='341'&action=edit
(note "pagesubpage=" where it first said "page=")

or change all instances of the word 'pagesubpage' in your script to 'page', i.e:  
... if ($_GET['page'] == '' and $_GET['sID'] != '') ...  

0
 
redcableAuthor Commented:
I dont know are you sure? maybe I need to change something else.

my link generators are below, and 'page=' isnt a variable

$_GET['pagesubpage'] is a variable, or do I need to define before I use it in the if statement?

 echo '    <tr "removed some stuff to save room''  . zen_href_link(FILENAME_SUBSCRIPTION_TRACK_ADM, 'page=' . $_GET['pagesubpage'] . '&sID=' . $customers->fields['subscription_id'] . '&action=edit', 'NONSSL') . '\'">' . "\n";
    } else {  
echo '       <tr "removed some stuff to save room'' . zen_href_link(FILENAME_SUBSCRIPTION_TRACK_ADM, 'page=' . $_GET['pagesubpage'] . '&sID=' . $customers->fields['subscription_id'] . '&action=edit', 'NONSSL') . '\'">' . "\n";
   
}
0
 
ShelfieldCollegeCommented:
those two echo lines there look like they're echoing $_GET['pagesubpage'] tp the page= variable (page=' . $_GET['pagesubpage']), try making that pagesubpage=' . $_GET['pagesubpage'] or if you decide to change all instances of $_GET['pagesubpage'] to $_GET['page'] then do it here as well. e.g. page=' . $_GET['pagesubpage']

It basically depends on whether you want to use the $_GET['page'] variable or $_GET['pagesubpage'] variable, i recommend using $_GET['pagesubpage'] as you only have a couple of lines to change then, anywhere it says page= on your link generators change it to pagesubpage=

Hope that's helped, if you've still got problems let us know.
0
 
redcableAuthor Commented:
yep i noticed this, and I was just wasnt paying attention, I gave my self a good wack, thanks for the help mates!!!
0
 
ShelfieldCollegeCommented:
Anytime, glad we could help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.