473,396 Members | 1,917 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

query the "most viewed" in ASP

here what i wrote :


Expand|Select|Wrap|Line Numbers
  1. <%
  2. path = Server.mappath("../db/ServerData.mdb") 
  3. set con = Server.createobject("ADODB.Connection") 
  4. con.open "driver={Microsoft Access Driver (*.mdb)};DBQ="&path 
  5. set r = con.execute("select * from News")
  6. Dim max
  7. Dim filename
  8. r.movefirst
  9. filename = r.fields("Name")
  10. max = r.fields("Views")
  11. do until r.eof
  12. if max < r.fields("Views") Then
  13. max = r.fields("Views")
  14. filename = r.fields("Name")
  15. r.movenext
  16. else
  17. r.movenext
  18. end if
  19. loop
  20. set t = con.execute("select * from News where Name='"&filename&"'")
  21. response.write "<table   width='2%' bgcolor='white'  marginbottom='0' margintop='0' align='center'>"
  22. response.write "<tr>"
  23. response.write "<th>Category</th>"
  24. response.write "<th>Header</th>"
  25. response.write "<th>Picture</th>"
  26. response.write "<th>Writer</th>"
  27. response.write "<th>Summary</th>"
  28. response.write "<th>Views</th>"
  29. response.write "<th>Link</th>"
  30. response.write "</tr>"
  31. response.write "<tr>"
  32. response.write "<td>"&t.fields("Category")&"</td>"
  33. response.write "<td>"&t.fields("Header")&"</td>"
  34. response.write "<td><img src='../"&t.fields("Picture")&"' width='50px' height='50px'></td>"
  35. response.write "<td>"&t.fields("Writer")&"</td>"
  36. response.write "<td>"&t.fields("Summary")&"</td>"
  37. response.write "<td >"&t.fields("Views")&"</td>"
  38. if t.fields("Category") = "Playstation" Then
  39. response.write "<td><a href='news/psnews/"&t.fields("Name")&"/"&t.fields("Name")&".asp' target='_top'>למעבר</a></td>"
  40. end if
  41. if t.fields("Category") = "Xbox" Then
  42. response.write "<td ><a href='news/xboxnews/"&t.fields("Name")&"/"&t.fields("Name")&".asp' target='_top'>למעבר</a></td>"
  43. end if
  44. if t.fields("Category") = "Nitendo" Then
  45. response.write "<td><a href='news/nitendonews/"&t.fields("Name")&"/"&t.fields("Name")&".asp' target='_top'>למעבר</a></td>"
  46. end if
  47. if t.fields("Category") = "Computers" Then
  48. response.write "<td><a href='news/computersnews/"&t.fields("Name")&"/"&t.fields("Name")&".asp' target='_top'>למעבר</a></td>"
  49. end if
  50. response.write "</tr>"
  51. response.write "</table>"
  52. t.close
  53. set t = nothing
  54. r.close 
  55. set r = nothing
  56. con.close
  57. set con = nothing
  58. %>
  59.  
its work for serval times but there times it dont work and choose the less views
Apr 23 '10 #1
2 1709
jhardman
3,406 Expert 2GB
change your query to
Expand|Select|Wrap|Line Numbers
  1. select * from News order by Views desc
This will list the articles most viewed first.

Jared
Apr 26 '10 #2
thx...............................
Apr 27 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: NotGiven | last post by:
I am guessing I would hold a variable of when it's opened, then in the script that runs when the page is offloaded, I coudl calcualte it. How do you store a time variable? How do you calculate...
4
by: la_haine | last post by:
I have a collection of pages that are designed to be called into an iframe (named displayView), and the managers don't want people to be able to view them unless they're in that iframe. If I use...
14
by: expertware | last post by:
Ok! to avoid confusion I will start a new argument. Thanks!! FIREFOX 1.0.7 AND IE6 viewed through DATATIME: a summary REPORT ===============================================================...
3
by: Damian | last post by:
Hi everyone I'm having an issue with one of our applications. I'm getting the following error when attempting to log in to the site: Server Error in 'xxxxxxxxxxxxxxxx' Application....
0
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
4
by: piscogirl | last post by:
Hi all, Here's my case: I have a form: Event Form and a subform: AttendanceSubForm The user selects a name (from a Person Table) on the subform to register for the event. If the name is...
1
by: Colleen | last post by:
Hello. I'm still somewhat new to PHP - taking an intro class. Is there a script I can code onto my .inc.php files to return viewers to the previous page viewed (without having to code to a...
6
by: wingedtiger | last post by:
http://www.dynamicdrive.com/dynamicindex13/trailer2.htm, this is the URL of a great script but it can only be viewed in internet explorer and opera firefox gives the error: dots.obj has no...
19
by: Viken Karaguesian | last post by:
Hello everyone, Just an observation here: the CSS newsgroup (comp.infosystems.www.authoring.stylesheets) is totally dead. Why?... Anyway here's my discussion point: What is the most versatile...
5
by: Alec | last post by:
I am starting the creation of a simple news website in PHP, and would like to include a section for the 'most viewed' or 'most popular' articles. As a beginner to PHP, I have looked on google...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.