- Zonehacks.com
- Forums
- PHP
- Working on my DJ pages.. new idea to make things easier...
Not logged in - Click here to login to your Account Welcome Guest!
|
Working on my DJ pages.. new idea to make things easier...
|
|
Author Info:
|
|
| mfoland Posted about 1 year ago. Total XP: 335 |
Yeah I over reacted. Sorry Specific. Generlly page should be non existant. That grabs the page number. I'll keep playing with it. If there is 6 on the page.. thats all it should view until you go to page 2, etc.. Also with page pagination for page number with the a href.. I can only do the first page on the second page.. like if on page too, newest 6 entries... page=1 etc. but even if I type page=3 that always stays on page 1 no matter what in the links.. not sure what I am doing wrong here.
Last modified by mfoland on March 31, 2009, 6:44 pm |
| Jordan Posted about 1 year ago. Total XP: 870 |
Are you building the LINK's to the other pages? or.. actually displaying the page??
such as yourwebsite.com/viewsomething.php?page=2&dj=1
Or, are you building the
< 2 3 4 5 >
type things? |
| mfoland Posted about 1 year ago. Total XP: 335 |
the 2345 type things. I already have the page thing working that I found.. if($match[1]<$highest) {echo '<a href="jockpage.php5?dj=$dj&page=' . ($match[1] + 1) . '">next</a>';} Eh.. cancel the php I entered.. for some reason the page isn't wanting to work.. still playing with that. lol it would then echo page=1, etc
Last modified by mfoland on March 31, 2009, 7:40 pm |
| Specific Posted about 1 year ago. Total XP: 4875 |
Remember me telling you there is a difference between ' and "? ' is literal while " can translate variables. for example 'the current dj is $dj' will echo just that while "the current dj is $dj" will translate $dj with whatever is stored in the variable. |
| mfoland Posted about 1 year ago. Total XP: 335 |
Right, but the ' is the start of the href. I think what I was trying to do was have it get the dj from when they originally click the link jockpage.php5?dj=dasplodge&page=1. That is what the $dj is suppose to do, so that when we go the next link, it will continue the dj name whatever dj they wanted to view. Last modified by mfoland on March 31, 2009, 11:13 pm |
| mfoland Posted about 1 year ago. Total XP: 335 |
EDIT: After reading about the pagination and what I'm trying to do.. Check this link out. It will show you how the pagination actually works. http://www.wlqt.com/pages/kimfaris.html?page=2 Thanks! OK, what I am trying to do with this is called Pagination. However, I have found scripts to do this, but it doesn't work for what I am doing. Here is what I'm trying to do: Database table: JockSite fields: dj, title, date, body I go to a page like djpage.php?dj=mike and it should bring up the first page (6 items). Then it should have a link to previous items.. bringing a link such as djpage.php?dj=mike&page=2 On that page it will show up page 2 stuff (6 more items). On that page it has a link like <<newer 6 entries which goes to the previous page and then previous 6 items which would go page forward (3).. and so forth. At this point I am stuck. I have been building various things on my site, such as a forecast system, and that is running perfectly. I have been toying with this pagination idea for quite some time and can't figure this out. Any help would be greatly appreciated! Mike Last modified by mfoland on May 27, 2009, 5:45 pm |
| Jordan Posted about 1 year ago. Total XP: 870 |
Well, ask yourself a few questions. 1) How many do i want per page You know how to use $_GET statements, all you're getting is the DJ and the page right?
So if the page isn't set, make it 1,
Then all you need to do is select it all, and use the LIMIT FROM, TO. which TO = Curr Page + how many entries.
Juat need to think over what you need. Give that a turn and see what happens. If you're still stuck let me know. |
| mfoland Posted about 1 year ago. Total XP: 335 |
yes, I know how to get the data, I want to limit 6 per page, which I know the limit function. I just am not sure how to make it do the links lol. Also, how would I make php set the date the entry was created upon submission. I have never figured that out, although I do know the date function. I'll try to play with it and see what I can do for the entries for the functions. |
| Specific Posted about 1 year ago. Total XP: 4875 |
In order for pagination to work properly, several variables need to be stored. These variables will provide the script with information about what page to show, how many pages there are, and how many results to show per page. Since the content you want separated into pages comes from the database, you can use SQL to your advantage. By using the MySQL limit command, we can specify what results we want from the database. For example, adding LIMIT 5, 5 to the SQL query will return five results starting from the fifth index. The syntax for the LIMIT command is [LIMIT {offset, row count}]. After connecting to your mysql server and selecting the database, the following should be done. First check if a page number is provided; if a page is not provided then just set it to 1. This is done by: $pageNum = (isset($_GET[‘page’])) ? $_GET[‘page’] : 1; The next step is to get the total number of results from the database. $result = mysql_query(“Select
COUNT(dj) AS totalCount FROM JockSite”); Create a variable to store the amount of rows to display per page. $pageRows = 6; Now we need to calculate how many pages there are total with 6 results per page. This is done by dividing the number of total rows by number of rows per page. Problem with this is that it will return a fraction. For example, 100 results / 6 rows per page equal 16.67 pages! To fix this the value has to be rounded up to the next integer value. So to get the last page number we will use the ciel function to round up if we have to. $lastPage = ceil($totalRows/$pageRows); Before we start shoving this data into a SQL mouth we should first check it to make sure there are no discrepancies. Is the page number provided out of bounds? If($pageNum < 1) { } Now the variables can be used to grab results from the database for each page, and display the page navigation. Using simple math, a SQL statement is created that will show results that are determined by what page the user is on. Because pages start at 1 instead of index of 0, the offset must be calculated by subtracting 1 from $pageNum. It would be silly to have pages start at 0. $pageOffset = ($pageNum-1) *
$pageRows; The results from the query can now be displayed using the while loop. while($row = mysql_fetch_array($result))
{ The script should now work displaying pages by changing the page in URI. The script now needs to be made accessible providing links to all the pages. When building the navigation, there is no point in showing a link for previous or first page, ditto if on the last page. If($pageNum != 1) { It’s optional and is totally up to the web master if he wants to add some in-between page numbers here. I will not go into this. Now to create the next and last links just opposite of how the first and previous were done. If($pageNum != $lastPage) { Now you should be able to create your own pagination. Last modified by Specific on May 28, 2009, 9:35 pm |
| mfoland Posted about 1 year ago. Total XP: 335 |
Thank you. Can I do a topic ASC to put the newest ones on the newer pages and the previous on older pages.. Topic stands for the title of the entry. |
Not logged in - Click here to login to your Account
| Topic Title | Forum | Last post Info |
|---|---|---|
| memheader.h | CPP | August 18, 2010, 12:07 am by boringwall |
| Aoc delete hack for voobly: Need help | Game Hacking | June 22, 2010, 9:36 pm by itsokman |
| Help deleting hacks | Game Hacking | June 6, 2010, 8:01 pm by Specific |
| Encryption | General Development | May 6, 2010, 3:04 pm by sypher |
| Hackshield Bypass | Game Hacking | August 18, 2010, 1:44 am by iPromise |

