Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help with these code!

Status
Not open for further replies.

fireburner69

Programmer
Aug 22, 2002
108
GR
OkI have these code that i use in a news section! But I can not understand where is the problem.

I want to make it to show the news from the last to the old one. I have done that but it seperates the pages in the other way! So when i have 15 news page One has 1 new page TWO has 7news and page 3 has 7news(which are the most recent news I input)

These is the code!


<%

Dim nPage, nItems
'Collects Page References
nPage = request(&quot;p&quot;)



'No Page reference taken then default to first page
if isnumeric(nPage) and nPage <> &quot;&quot; then
if nPage > 0 then
nPage = cint(nPage)
else
nPage = 1
end if
else
nPage = 1
end if

'How many items to display per page
nItems = 7

' Define variants
Dim numID, strTitle, strStory, strLink, strSubmittedBy, strDatestamp, adOpenStatic, adLockReadOnly, adCmdTable, numCounter
adOpenStatic = 1
adLockReadOnly = 1
adCmdTable = 2


' Define database file type and location
Dim objConn, objRS, nRecordCount, nPageCount, nPageSize, sPrev, sNext
Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set objRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)

objConn.Open &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _
&quot;Data Source=\\athcfs01.hosting.forth\virtual\speftp\db\news.mdb;&quot; & _
&quot;Persist Security Info=False&quot;


' Open News table in database
objRS.Open &quot;News&quot;, objConn, adOpenStatic, adLockReadOnly, adCmdTable

' Move to the last record
objRS.MoveLast


objRS.cachesize= 3
objRS.PageSize = nItems

nRecordCount = objRS.RecordCount
nPageCount = objRS.PageCount
nPageSize = objRS.PageSize

if Cint(nPage) <= Cint(nPageCount) then
nPage = nPage
else
nPage = nPageCount
end if

objRS.AbsolutePage = nPage





'Display the data

if not objRS.EOF then
nRecordCount = 0
Do While Not objRS.BOF and nRecordCount < nPageSize

'Do until objRS.eof
response.Write(&quot;<p>&quot;)
if objRS(&quot;Link&quot;) <> &quot; &quot; then
response.write(&quot;<img src='linkicon.gif'> &quot;)
End If
response.Write(&quot;<a href='showstory.asp?storyid=&quot; & objRS(&quot;ID&quot;) & &quot;'>&quot;)
response.Write(objRS(&quot;Title&quot;) & &quot;</a>&quot;)
response.Write(&quot;<br><small>&quot; & objRS(&quot;Datestamp&quot;) & &quot;</small><br><br>&quot;)
response.Write(&quot;</font></p>&quot;)
' objRS.MoveNext

' Do While Not objRS.eof and nRecordCount < nPageSize
nRecordCount = nRecordCount + 1
objRS.MovePrevious
loop




Else
response.write(&quot;No Records&quot;)
End if

' Create the navi
if Cint(nPage) = Cint(1) or Cint(nPage) = 0 then
sPrev = &quot;<< Prev&quot;
Else
sPrev = &quot;<a href=&quot;&quot;table.asp?p=&quot; & (nPage - 1) & &quot;&quot;&quot;><< Prev</a>&quot;
End if
if Cint(nPage) = Cint(nPageCount) then
sNext = &quot;Next >>&quot;
Else
sNext = &quot;<a href=&quot;&quot;table.asp?p=&quot; & (nPage + 1) & &quot;&quot;&quot;>Next >></a>&quot;
End if


'if not objRS.eof then
' Display the Navi
response.write(sPrev & &quot; | <b>&quot; & nPage & &quot;</b> of &quot; & nPageCount & &quot; | &quot; & sNext)

' Close & clean up
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>



Thanx for yout time and sorry for my English! :)
 
Hello fireburner69 ,

I am confidant that You will find a solution to the problem if you use the group by clause in the sql query. You can easily find the number of news each one has, and you can take the appropriate action.
If u still find trouble,let me know so that i can help you intensively
 
yes but where do i put the code?
I know that the problem is that seperates the news before it display them but i can not understand why? i Say to go to the last of the news and then to display but! why it seperates the news?

I hope you can help me!

Thaxn for your time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top