Results 1 to 9 of 9
May 1st, 2006, 12:47 PM #1
[php][mysql]Display Highest news id
I have a php/mysql news management system, and on my main page i want to display my latest news. Basically i need to include the page with the highest news id my pages are set like this:
Is there a way to do this?
May 1st, 2006, 12:50 PM #2
you need your query to be something like:
$result = mysql_query( "SELECT * FROM newstable LIMIT limitnum ORDER BY newsid ASC" )'
May 1st, 2006, 01:32 PM #3602Backend Specialist
May 1st, 2006, 01:41 PM #4
May 1st, 2006, 02:26 PM #5
then LIMIT 1
@skoob: word. i couldn't remember the syntax off hand.
May 1st, 2006, 03:15 PM #6
Would it be ordered by DESC? To get the latest news?Member #2 of the "I wont critique Timmytot's designs anymore" club.
May 1st, 2006, 03:30 PM #7602Backend Specialist
you should really have a datetime field on the news entry. like "date_added" or something, and use that for ordering. using an auto_increment ID could work...but it won't work if for some reason you insert an ID manually to a lower available news ID.
@ sebs - Since the news ID will be 1 more than the previous news story, it will have a greater number, and you want to sort from highest to lowest to get the most recent news story added.
May 1st, 2006, 03:36 PM #8Originally Posted by skOOb
and sort by DESC 4 would be at the top, that woudl be the newest story.Member #2 of the "I wont critique Timmytot's designs anymore" club.
May 2nd, 2006, 08:05 AM #9
try this sql statement:
$result=mysql_query("select max(id) as maxID from tbltable");
this would output the maximum id number in the database
Web Solution Provider
By prada in forum Flash IDEReplies: 0Last Post: April 19th, 2006, 10:40 AM
By sebstence in forum Flash IDEReplies: 1Last Post: February 22nd, 2006, 09:59 PM
By mseerob in forum Flash IDEReplies: 0Last Post: February 2nd, 2006, 10:09 PM
By luxxx in forum ActionScript 2 (and Earlier)Replies: 0Last Post: January 30th, 2006, 09:12 PM
By Nischint in forum Server-Side (PHP, SQL, ASP.NET, etc.)Replies: 11Last Post: September 8th, 2001, 02:54 PM