There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot computer connection crash css dell display driver drivers email error ethernet excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem router slow software sound trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: Pagination


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
14-Oct-2007, 05:25 AM #1
Solved: Pagination
Hello i'm quite good at PHP but this just isnt working for me, Pagination. Please could someone show me how to use it i want the Results to show below spilt up into pages


HTML Code:
$select =mysql_query("SELECT * FROM `1` ORDER by `id` WHERE `cat`='Hardware' ");
while ($i = mysql_fetch_object($select)){
echo"<a href=\"view.php?viewid=$i->id\">$i->name</a></p>";
MMJ's Avatar
MMJ MMJ is online now
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
14-Oct-2007, 05:01 PM #2
Whats the error you are getting?
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
14-Oct-2007, 05:04 PM #3
It was something about LIMIT 1 or something i don't know i deleted it in the hope of someone beening able to come up with something on here
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,715 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
15-Oct-2007, 07:20 PM #4
Please excuse me for asking but this doesn't look right:

while ($i = mysql_fetch_object($select)){
echo"<a href=\"view.php?viewid=$i->id\">$i->name</a></p>";

That looks like for each iteration of the loop, you're closing a paragraph element (the </p>) yet I don't see where the paragraph is being opened. Is this correct/intentional?

Peace...
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
16-Oct-2007, 02:42 AM #5
Oh sorry my mistake i had a </p> on the end
MMJ's Avatar
MMJ MMJ is online now
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
16-Oct-2007, 07:28 AM #6
Try this:

PHP Code:
<?php
$select 
mysql_query("SELECT * FROM `1` ORDER BY id WHERE cat = 'Hardware'");
while (
$i mysql_fetch_object($select)) {
echo 
"<a href='view.php?viewid=$i->id'>$i->name</a>";
}
?>
If that doesn't work than post the exact error you are getting, PHP or SQL.
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
16-Oct-2007, 10:35 AM #7
That code is ok, i am wanting the same code but so it puts the results into pages
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,715 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
16-Oct-2007, 10:39 AM #8
Something like this: (pseudo-code)

Code:
<?php
$select = mysql_query("SELECT * FROM `1` ORDER BY id WHERE cat = 'Hardware'");
while ($i = mysql_fetch_object($select)) {
// Generate a HTML page here
}
?>
Peace...
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
16-Oct-2007, 11:54 AM #9
I dont think you get me

I want them Results what would be generated by that script put into PAGES so like a pagination script ...
tomdkat's Avatar
Computer Specs
Distinguished Member with 3,715 posts.
 
Join Date: May 2006
Location: S.F. Bay Area, CA
Experience: Intermediate
16-Oct-2007, 12:03 PM #10
So, then something like this:

Code:
<?php
$select = mysql_query("SELECT * FROM `1` ORDER BY id WHERE cat = 'Hardware'");
while ($i = mysql_fetch_object($select)) {
// if page-break threshold is reached
//   kick out a page break and start a new page
// process current row in result set
}
?>
Of course, I'm not sure what your definition of a "page" is (HTML page, page in a document that will be generated, something else entirely) but the above algorithm might do what you want.

Peace...
bob121's Avatar
Senior Member with 188 posts.
 
Join Date: Sep 2006
16-Oct-2007, 01:29 PM #11
That does not put the results into pages . . .
MMJ's Avatar
MMJ MMJ is online now
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
17-Oct-2007, 08:25 AM #12
Quote:
Originally Posted by bob121
That does not put the results into pages . . .
Oh, ok.

http://www.google.com/search?q=pagination+php
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:52 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.