PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 26th, 2002, 08:40 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
limit results from mySQL?

Hello:
I am new to PHP and trying to limit results from a mySQL query. basically I would like to know the best practice for doing somethign like this.

I have a table in mySQL that I am trying to pull three fields from for items equal to or older than *today* limit the results to five and print those to the screen in a particular format.

I thought I should use something like this:
<?PHP
(connection string)
Select folderName, galleryName, entryDate from Gallery where entryDate <= *today?* limit 5 order by entryDate DESC;

{
echo "<a href=/galleries.php?folder=$folderName>$galleryName</a><br>"
}
?>

any advice would be greatly appreciated. I am not really sure but I think I need to loop? how do I do that? and also I am not sure about how to format the *today* so that it compares and also sorts.

Thanks in advance.
--
Todd

Reply With Quote
  #2  
Old August 26th, 2002, 09:13 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: limit results from mySQL?

The LIMIT clause should be after the ORDER BY clause.

After you do your query (via mysql_query), you will need to loop using one of: mysql_fetch_array, mysql_fetch_row, or mysql_fetch_assoc.

If entryDate is a DATE field, using NOW() should work for *today*.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > limit results from mySQL?


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
Stay green...Green IT