Jump to content


Photo

pagination and dated layout


  • Please log in to reply
1 reply to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 September 2006 - 06:31 PM

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
<?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;
			}
?>
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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 19 September 2006 - 08:28 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users