Log In
Sign Up
Why Join Hot Scripts?
Hot Scripts
All Categories
PHP
Python
Tools & Utilities
XML
Ruby on Rails
Ajax
Web Hosting
ASP
ASP.NET
C & C++
CFML
Flash
Java
JavaScript
CGI & Perl
HTML5
Forums
Blog
Scripts
Hosted Apps
Plugins
Design Templates
Forum
Blog
Advertise
Contact Us
Register
FAQ
Rules
Calendar
Search
Today's Posts
Mark Forums Read
RSS Feeds
Current location:
Hot Scripts Forums
»
Programming Languages
»
PHP
» Select last entry from DB
Select last entry from DB
LinkBack
Thread Tools
Display Modes
#
1
(
permalink
)
11-21-03, 02:26 PM
perleo
Coding Addict
Join Date: Jul 2003
Location: Ireland
Posts: 269
Thanks: 0
Thanked 0 Times in 0 Posts
Select last entry from DB
I have a mysql db but i want mysql to select with a limit for 4 rows but it must be the last 4 rows in the table as this db will be updated daily.
PHP Code:
$sql
=
"SELECT * FROM news LIMIT 0, 4"
;
how do I do this ?
perleo
View Public Profile
Find all posts by perleo
#
2
(
permalink
)
11-21-03, 04:04 PM
mdhall
Aspiring Coder
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
PHP Code:
$sql
=
"SELECT * FROM news LIMIT 0, 4"
;
You can use this...
$sql = "SELECT * FROM news ORDER BY id DESC LIMIT 4";
This gives you the 4 newest entries, in descending order. Use ASC to reverse them.
Also can by ordered by timestamp, if you have one inserted in a field.
__________________
http://grumpy-people.com
http://diecastsforsale.com
mdhall
View Public Profile
Find all posts by mdhall
Bookmarks
Digg
del.icio.us
StumbleUpon
Google
«
incorrect code, plz show me real code
|
What to watch when implementing an upload script
»
Currently Active Users Viewing This Thread: 1
(0 members and 1 guests)
Thread Tools
Show Printable Version
Email this Page
Display Modes
Linear Mode
Switch to Hybrid Mode
Switch to Threaded Mode
Posting Rules
You
may not
post new threads
You
may not
post replies
You
may not
post attachments
You
may not
edit your posts
BB code
is
On
Smilies
are
On
[IMG]
code is
Off
HTML code is
Off
Trackbacks
are
On
Pingbacks
are
On
Refbacks
are
On
Forum Rules
Forum Jump
User Control Panel
Private Messages
Subscriptions
Who's Online
Search Forums
Forums Home
General Community
Announcements
Polls
The Lounge
New Members & Introductions
Script Requests
HotScripts.com Discussion
Hot Scripts Forum Questions, Suggestions and Feedback
General HotScripts Site Discussion
HotScripts Site Bug Reports
General Web Coding
HTML/XHTML/XML
HTML5
JavaScript
CSS
Flash & ActionScript
Programming Languages
PHP
Perl
ASP
ASP.NET
C/C++
Visual Basic
Windows .NET Programming
Everything Java
Other Languages
Other Discussions
Web Servers
Database
Other Topics
Web Design
API
Frameworks
AJAX
Security
Server Administration
Portable Device Programming
Cloud Computing
Ruby on Rails
CFML
Python
Tools and Utilities
Remotely Hosted
Web Hosting
Advertising Forums
General Advertisements
Job Offers & Assistance
Traffic Exchange
Website Reviews
Web Hosting Talk
DBForums.com
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Select Skin
awais
PHP
5
01-02-04
02:37 PM
Help me select a e-commerce system
omnidust
Script Requests
3
10-08-03
12:38 AM
Insert...select
andreasberglind
PHP
5
08-21-03
05:07 PM
PHP Can't select database
EST
PHP
4
08-19-03
10:14 AM
What if there is no entry?
Cagez
PHP
3
07-29-03
02:06 AM
All times are GMT -5. The time now is
05:57 AM
.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
LinkBack
LinkBack URL
About LinkBacks
Bookmark & Share
Digg this Thread!
Add Thread to del.icio.us
Bookmark in Technorati
Share on Facebook
Share on Stumble Upon
Share on Twitter