View Full Version : Auto redirect to Last record
Daryl
11-22-2011, 12:12 AM
I have a page which uses a URL variable to get its data from a database
news-detail.php?News=1
Is there a way to get the page to redirect to the last record if no URL variable is present?
ie news-detail.php would get redirected to news-detail.php?News="Last Record"
CraigR
11-22-2011, 05:16 AM
what i would do is use the News ID from your url parameter as your recordset filter.
you could have an additional recordset on your page which would return the Max news ID from your table
something like "SELECT max(NewsID) AS MaxNewsID FROM tblnews"
if the recordset returns no rows (ie you have no matching record) you use this instead of the url parameter as your recordset filter
Daryl
11-22-2011, 06:39 AM
So is there a way of 'showif' url variable, 'showif' no url variable?
CraigR
11-22-2011, 06:54 AM
what i meant was using the server behavior
show if recordset is empty/not empty
if the recordset returns a row, you show the information returned
if the recordset doesnt return a row, your max news id would come into play
so the psudologic would be..
if first recordset returns a row, show it
if first recordset is empty, use the max news id that is present as a filter instead
Daryl
11-23-2011, 03:48 AM
Ah I see - pretty obvious realy
Thanks for your idease!
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.