Thanks again for taking the time to help me out on this issue bpat. I've got a pretty good grasp on the SQL side of things but am having a little trouble wrapping my head around how to break this up into multiple pages. Let me try to better explain what I'm trying to do.
I'm not sure if you would term it "pagination" or "sectionalization." I do want to break my results up into individual pages. Page one contains info for school one, page 2 for school two, etc. I have the current output nicely formatted with each schools info broken up.
With normal pagination, I would look at the total number of rows in the database (let's say for example that it was 300) and then I would set the variable $rowsPerPage (let's say $rowsPerPage=20). I would then have my results broken into 15 pages. Right?
For this task, I don't need to know rows per page. I can get the total number of pages like this...
$schoolCount="SELECT COUNT(DISTINCT school) FROM active";
$result = mysql_query($schoolCount, $conn);
$totalPages = $result
I think my biggest problem is figuring out what $offset is so I can use it in my LIMIT clause.
Again, in standard pagination, I would be doing something like this...
$rowsPerPage = 18;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
Then I could write my SQL like...
$sql="SELECT last_name, first_name, six_digit, home_address, school, one_bus, one_time, three_bus, three_time FROM active ORDER BY last_name LIMIT $offset, $rowsPerPage";
Would I know just totally get rid of my LIMIT clause???
I'm sorry if this is a bit wordy. I just think this should be a fairly simple problem and I'm probably making it out to be more complicated than it is. Again, I just can't get my head around it.
Any help is very much appreciated.