News:

The "Support Requests" forum is now viewable by guests.

Main Menu

MySQL Organizing Output, LIMITING???

Started by sixthcrusifix, January 28, 2006, 12:32:32 AM

Previous topic - Next topic

sixthcrusifix

I have a Gallery script which uses MySQL,

How can I make it so that if there are more than 30 results it will Stop at # 30 and create an index, the user can push "next" or whatever and see the rest of the list in they way they orderd it starting from the last pic they saw to  the end of the seiries?

I've tried LIMIT 30

But there's something else that I need and I Can't figure out how to do it efficiantly without making a bunch of cooky loops and arrays.
Visite me website at http://www.sixthcrusifix.com

sixthcrusifix

uh sorry to double post but this is really important because I still haven't found an easy way to do this.

I want it to be like this forum, there are tons of threads, but only 20 a page are listed.

I keep my gallery image info with MySQL and the user can list it by username, date or keywords.
Visite me website at http://www.sixthcrusifix.com

Evilsprouts

Umm I think you can do LIMIT 0, 30

that's to start from the first record and go to the 30th and u use a loop to increase the 0 by 30.so on page 1 it will be from record 1 - 30 page 2 will be record 31 - 60 etc.

My version is a little longer than it could be but it works for me so

sixthcrusifix

Quote from: Evilsprouts on February 01, 2006, 06:16:44 PM
Umm I think you can do LIMIT 0, 30

that's to start from the first record and go to the 30th and u use a loop to increase the 0 by 30.so on page 1 it will be from record 1 - 30 page 2 will be record 31 - 60 etc.

My version is a little longer than it could be but it works for me so

Well that sounds cool. Lims worked on my Shoutbox Script when I used IDs (that were key, auto increase) But for some reason limit won't work for me here. :C When I use it  get no results, it doesn't limit anything. The only way I've even been able to limit the amount of display on 1 page is through a while loop and an increasing variable. Maybe you could give me your version, I don't mind how long it is.
Visite me website at http://www.sixthcrusifix.com

Evilsprouts

Ok I'm in a bit of a rush at the moment but hear goes,

This is the old system I used ages ago just next and previous.

This bit displayed the links:
<table>
<tr>
<td align="center" width="75"><a href="http://www.yoururl.com/page.php?&start=<? echo $start - 10; ?>">&lt;PREV</a></td>
<td align="center" width="75"><a href="http://www.yoururl.com/page.php?&start=<? echo $start + 10; ?>">NEXT&gt;</a></td>
</tr>
</table>


Put this bit in you query
LIMIT $start, 10

Hope this helped.

webzone (archived)

I may look like a paranoid, but be sure to use intval() or addslashes() on $start to avoid SQL injection.