Jump to content

pagination and dated layout


Ninjakreborn

Recommended Posts

I put it off on an older project.  I didn't know how at the time, and that site won't need it for a long time.  This one however, is a project I have no choice but to use that on.  Expcept that the layout behind hte programming is like 8 search results for each section, on one page.

In a giant case switch statement
[code]<?php
// get together the critical variables, and clean them up.
$postset = mysql_real_escape_string($_GET['ps']);
$school = mysql_real_escape_string($_GET['s']);
$category = mysql_real_escape_string($_GET['c']);
$subcategory = mysql_real_escape_string($_GET['sc']);
// go through databases.  Easier to keep up with, let's start with database number 1
switch ($postset) {
// Work with database postset1
case "postset1":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset2
case "postset2":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset3
case "postset3":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset4
case "postset4":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset5
case "postset5":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset6
case "postset6":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset7
case "postset7":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
// work with database postset8
case "postset8":
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND
subcategoryname = '$subcategory' AND schoolname = '$school';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) {

}
break;
}
?>[/code]
looking on this, it is obvious I haven't actually started working with displaying yet. I have 2 things I am having to do here, and neither one of them I am 100% sure on how to do.  I am going to pull just the title of the title out and display it(that will be the results), but it will be a link going to one of the results page.  That part is easy, just have it appear as a link, and past the post id to one of the 8 table handlers.  I have 8 pages, 1 for each table results, or maybe even 1 page with another switch statement to handle them all, whatever, that's easy.  For this though, on this page, I am just shwoing the title of the post.  That is also pretty easy.  Now here comes the difficult thing, I have 2 goals i have to accomplish and I am not sure how
These are related to this 1 page
1. Seperate them by date.  I have the date saved in the database, of when they were posted, but I am unsure, (sort of  like craigslist), to allow them to show a date, everything for that date, show the next date, and everything for that date.  That type of setup.  Then after 30 days the admins clear it, and the ones older than 30 days are dropped
2. Pagination, I want to show about 1-200 per page.  And hten have multiple pages, based on the number of total search results.
Link to comment
Share on other sites

I was told earlier something about session arrays.
Can I save this information in a session
lile
$_SESSION['pagination'] = array()
and set the array with the different variables for count and stuff.  I was thinking about this now, because if I can, and it will keep it seperate totally from the logged in related sessions, then I think it would be a good idea.  Then again, won't it make them come back to those search pages, everytime.  Is there a bad thing about setting it up this way.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.