This topic is locked

Count entries on menu page

4/28/2005 11:36:20 AM
ASPRunnerPro General questions
author

I have an application with a menu page where I can go to the New orders and display all the orders with the status new.
I want to be able to display on the menu page next to the "New orders" link the count of how many new orders I have. example:
Menu
Item count
New orders 5
Is there any way to do this?

Sergey Kornilov admin 5/4/2005

Hi,
you need to modify menu.asp file.

Here is an example:

<%

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

Set rs = server.CreateObject ("ADODB.Recordset")

strSQL = "select count(*) from Cars"

rs.open strSQL,dbConnection, 1, 2

%>
<a href="Cars_list.asp">Cars</a> Records: <%=rs(0)%>



Add this string to menu.asp file:

<!--#include file="include/..._dbconnection.asp"-->

501193 5/4/2005

Thank you,
The code works correctly, but now I need the result of the count to give a result based on the session userid
Example
I start the session with the user id = John

I want the count to correspond only to his records

and the count result be placed next to the item in the menu generated by ASPrunner
Code example
Call GetTables(Session("UserID"))
if InArray("dbo.AGREGARV") then
Response.Write "<a href=""AGREGARV_list.asp"">SOLICITAR VIATICOS</a>
"

end if
*how can I place the count result next to SOLICITAR VIATICOS

Sergey Kornilov admin 5/5/2005

Hi,
here is an updated code snippet:

<%

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

Set rs = server.CreateObject ("ADODB.Recordset")

strSQL = "select count(*) from TableName where UserIDField='" & Session("UserID") & "'"

rs.open strSQL,dbConnection, 1, 2

%>
<a href="Cars_list.asp">Cars</a> Records: <%=rs(0)%>


Change code in bold to match actual table/field names.

O
ORIONSYS 5/5/2005

Thanks again it works great, one last question
In the code that you sent me, you specified the variable
Set rs = server.CreateObject ("ADODB.Recordset")
with this I can put in my web page <%=rs(0)%> and get the result of the count records statement.
I need this result to go next to the corresponding link of the menu that is generated by Asprunner.
Example code generated by ASPrunner
Dim arr
Call GetTables(Session("UserID"))
if InArray("dbo.AGREGARV") then

Response.Write "<a href=""CARS_list.asp"">CARS</a>
"

end if
I want the count result <%=rs(0)%> to be displayed next to "">CARS</a>
So when I display the web page I get
CARS 5 (where 5 is the result of the count)
Sorry for so many questions but I cant get it to display the count in the menu I can get it to work in any other part of the web page but not here.

Sergey Kornilov admin 5/10/2005

Hi,
here is an updated code snippet:

Dim arr

Call GetTables(Session("UserID"))

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

Set rs = server.CreateObject ("ADODB.Recordset")

if InArray("dbo.AGREGARV") then

*  strSQL = "select count() from Cars"

  rs.open strSQL,dbConnection, 1, 2

  Response.Write "<a href=""CARS_list.asp"">CARS</a>
" & rs(0) &  "**
"

end if