PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old October 14th, 2003, 07:16 PM
banx banx is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 33 banx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
How can I get a fixed number of Headlines in this PHP script?

Mitch built a Multi-Page Article System script, http://www.devarticles.com/art/1/310 , it works great, but can anyone tell me how I can get a fixed number of headlines to be shown, like 20 or 25 headlines. Instead the entire listing.

THANKS!

Last edited by banx : October 14th, 2003 at 07:18 PM.

Reply With Quote
  #2  
Old October 15th, 2003, 01:32 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 7
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Notice the sql query:
PHP Code:
 $result mysql_query("select * from articles order by articleId asc"); 
What you can do is alter this query to only select a certain amount of records using the Limit clause.

Limit takes two parameters ( one is optional ). If you only supply one argument, that argument tells MySql to return at maximum that amount of records.

If you supply two arguments, the first is where to start (the offset of first row), the second argument is the max # of records to retrieve. To return 25 records:

PHP Code:
 $result mysql_query("select * from articles order by articleId asc LIMIT limit 0, 25"); 
This will not skip any records, but will limit the records returned to 25.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old October 15th, 2003, 03:04 PM
banx banx is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 33 banx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks for replying!

I tried that but then I get this
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in showarticles.php on line 14



And here is whats on line 14

Quote:
while($row = mysql_fetch_array($result))


Which leaves me to wonder, what could be wrong with line 14?

Reply With Quote
  #4  
Old October 15th, 2003, 03:07 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
That usually means you haven't connected successfully to the database or that the query is hosed. Echo your query before executing it and try running it at the command line. If it fails, then you've typoed on the query.

Reply With Quote
  #5  
Old October 15th, 2003, 05:11 PM
banx banx is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 33 banx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I thought so too. Which is what really had me scratchin' my noggin'.

It turns out, however, in:

Quote:
$result = mysql_query("select * from articles order by articleId asc LIMIT limit 0, 25");
I had LIMIT written twice.

Duh!

Thanks for your help guys! The script looks great now!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > How can I get a fixed number of Headlines in this PHP script?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway