PDA

View Full Version : Query for 10 current records?


mattboy_slim
04-22-2003, 08:28 PM
I need a query to grab only, say 10 records, rather than display everything from the current date forward. Our old web developer is unreachable, and I don't understand his code, nor can I think how to query only 10 records from our database.

What I need to query is 10 records from today forward for the events calendar. Right now the page is literally 20,000 pixels long since it is displaying all events on the front page.

The following is the code that displays the events currently.

All help is appreciated.
Matt


<%

function GoodDate(input)
GoodDate = WeekdayName(Weekday(input)) & ", " & MonthName(Month(input)) & " " & Day(input)
end function

set events = server.createobject("adodb.recordset")

Select_SQL = "Select * from t_events where ev_dt_end >= '" & date & "' order by ev_dt_start, ev_dt_end, ev_name"
events.open Select_SQL, bojiConn

if not events.eof then
%><hr>
<table border=0 width="100%" cellpadding=0 cellspacing=0>
<tr>
<td width=30 valign=top><a href="events/"><img src="images/upcoming_events.jpg" width="30" height="119" border="0"></a></td>
<td align=center width=100%><table width=100% border=0>
<tr>
<td><%
count = 0
do while not events.eof
%>
<%=events("ev_name")%><br>
<%=GoodDate(events("ev_dt_start"))%><%if events("ev_dt_end") <> events("ev_dt_start") then%> - <nobr><%=GoodDate(events("ev_dt_end"))%></nobr><%end if%><br>
<%if events("ev_location") <> "" then%><i><%=events("ev_location")%></i><br><%end if%></tr></td><tr><td>
<%
if count >= 2 then exit do
events.movenext
loop

events.close
set events = nothing

%>

raf
04-22-2003, 08:38 PM
What database are you using?

For Access and SQL server, use

select TOP 10 * from etc

mattboy_slim
04-22-2003, 09:09 PM
Yes, it's SQL Server 2000.

I'll give it a shot, thanks.

mattboy_slim
04-22-2003, 09:12 PM
Awesome raf, just awesome. That worked perfect. Simple as that. You guys here, as I always say, are beyond awesome.

raf
04-22-2003, 09:19 PM
We try to stay humble, modest and helpfull.

Glad you got it working.