Gossamer Forum
Home : Products : DBMan : Customization :

Retrive last record

Quote Reply
Retrive last record
Is there a way to set a link that will retrive the last added record to the database? And for the last 4 records?

Sorry if that sounds stupid but I'm no programmer...
Quote Reply
Re: Retrive last record In reply to
I think I figured it out myself. You might still help me if your idea is better then mine... (which is to set the search terms to sort by date, descending with number of records to show=1 and id=*)
Quote Reply
Re: Retrive last record In reply to
I want to have a script which get the last ten records and print them out but my database has no "date" field. No search and sorting function is needed.

Can anyone tell me how to do it?
Quote Reply
Re: Retrive last record In reply to
Rock,

My database didn't need the date field as well, but in order to have tha ability to have the last records I added it and I don't show it on the view output.
Quote Reply
Re: Retrive last record In reply to
In order to find the last x number of records added, you have to either have a date field or a numeric db_key that is generated by DBMan ($db_key_track = 1) and is uneditable. (The latter is probably preferable, because you might have more than x records added in a day and you wouldn't necessarily get the last x records if you used a date field.)

In the URL to search for the last x records, set
$db_key=*
mh=x [the number of records you want to show]
sb=[the field number of your $db_key]
so=descend

If you'd rather have a date field than a numeric key, change
sb=[the field number of your date field]

What you'll get is the last x records added on the first page, with the rest of the records available in the page bar at the top.


------------------
JPD