The static page is generated, and the things inside are static. But some things must change
Such as: articles clicks, articles ranking, etc.
The method is to solve this problem with <script>.
When we open this static page, we will read the number of clicks at this time
1. Add clicks in the template page and add after the number of clicks:
| The following is the code fragment: <script src = "counter.asp? ID = $ ID $"> </script> |
Remarks: In the file that generates HTML, the $ ID $ is replaced with the ID number of the article in the database
2.Counter.asp
| The following is the code fragment: <% DIM ID, SQLSTR, HITS Id = int (trim (Request.querystring ("ID")) SQLSTR = "Update News Set Hits = Hits 1 Where ID =" & ID 'Clicks to the article and add 1 conn.execute (SQLSTR) 'Read an article clicks Hits = const.execute ("Select hits from news where id =" & ID) (0) (0) %> 'Output articles clicks document.write (<%= hits%>) |
Mysterious problems: 1. Database does not create objects! For example:::
| The following is the code fragment: set guconn = server.createObject ("adodb.connection") Guconn.open mm_guconn_string |