954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php/mysql Help Needed ( Badly )

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 .

killer007
Newbie Poster
11 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 
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;
buddylee17
Practically a Master Poster
697 posts since Nov 2007
Reputation Points: 232
Solved Threads: 137
 

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)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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;

rudevils
Junior Poster in Training
80 posts since Jan 2008
Reputation Points: 10
Solved Threads: 10
 

Using ORDER BY is the best and easy way

vssp
Junior Poster
199 posts since Jul 2006
Reputation Points: 5
Solved Threads: 5
 
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.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You