Hello Guys Can anybody here answer my this question.

How we can show Latest Categories from this Sql table.

Here is the Table


-- 
-- Table structure for table `jos_afm_cats`
-- 

CREATE TABLE `jos_afm_cats` (
  `cat_id` int(11) NOT NULL auto_increment,
  `parent_id` text NOT NULL,
  `file_id` int(11) NOT NULL default '0',
  PRIMARY KEY  (`cat_id`)
) ENGINE=InnoDB DEFAULT CHARSET=cp1251 AUTO_INCREMENT=12 ;

-- 
-- Dumping data for table `jos_afm_cats`
-- 

INSERT INTO `jos_afm_cats` (`cat_id`, `parent_id`, `file_id`) VALUES 
(9, '0', 43),
(10, '9', 50),
(11, '0', 51);

Its a Joomla Component Called "AFiles" But Support on Programmers forum is Nill and Guy dont know English well .. So can you please Help me .

ALTER TABLE jos_afm_cats add column date TIMESTAMP ;

This will add a field called date which will record the date and time that the value was entered. Then when you pull the data using a SELECT command, use ORDER BY date DESC at the end of the query. So to pull the 5 most recent, Use:

SELECT * FROM jos_afm_cats ORDER BY date DESC Limit 5;

I agree with buddylee17. Without having a timestamp field or an autoincrement field, you can't make out which record was added last.

Edit: you can make use of rowid (i think)

I agree with buddylee17. Without having a timestamp field or an autoincrement field, you can't make out which record was added last.

Edit: you can make use of rowid (i think)

I think you can use row cat_id (`cat_id` int(11) NOT NULL auto_increment).
maybe you can order it like this
SELECT * FROM 'jos_afm_cats' ORDER BY 'cat_id' ASC;

I think you can use row cat_id (`cat_id` int(11) NOT NULL auto_increment).

Oops! I didn't see that OP has an auto increment field.

maybe you can order it like this
SELECT * FROM 'jos_afm_cats' ORDER BY 'cat_id' ASC;

And yep, that's what I was talking about.

This article has been dead for over six months. Start a new discussion instead.