Author |
Topic |
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 09 March 2002 : 16:17:07
|
On my site I have a list of the DVDs that I own. Right now I have to manually edit the page if I buy a new DVD and want to add it so I added the DVD's table from my "inventory" database into my test forums' database.
I used the Smilies MOD by Stimmy to be able to add new DVD's which works fine except that I can't edit the info nor delete them (I'm getting new code for this all soon).
What I'm looking for is something to count the DVD's that are in the DB. So actually it'd count the records. Then that number could be shown on the top of the page.
The table is called FORUM_DVD and I'm ordering the DVD's by ID. Could anyone give me the basic code to count how many records there are in the table?
Thanks.
http://www.frutzle.com
Snitz Exchange | Do's and Dont's |
|
OneWayMule
Dev. Team Member & Support Moderator
Austria
4969 Posts |
Posted - 09 March 2002 : 16:32:05
|
strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM FORUM_DVD"
I think this should work.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 09 March 2002 : 16:33:20
|
strSql = "SELECT count(ID) AS cnt FROM DVD_TABLE" set rs = Conn.execute strSql numberOfDVDs = rs("cnt")
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 09 March 2002 : 16:33:49
|
I've been beaten !
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
|
Doug G
Support Moderator
USA
6493 Posts |
Posted - 09 March 2002 : 19:10:09
|
Since I'm too late, all I can offer is
"There are 3 kinds of people, those who can count and those who can't."
====== Doug G ====== |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 09 March 2002 : 20:07:01
|
quote:
Since I'm too late, all I can offer is
"There are 3 kinds of people, those who can count and those who can't."
====== Doug G ======
Roland ... read that ^ again!
Doug ... ... funny guy
Nikkol |
|
|
Nathan
Help Moderator
USA
7664 Posts |
Posted - 09 March 2002 : 20:14:33
|
Hehe, get out your calculator and add up those types Frutz
Nathan Bales - Romans 15:13 ---------------------------------- Snitz Exchange | Do's and Dont's |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 09 March 2002 : 20:30:55
|
Hey I didn't use a calculator and it's 2:30am... (can't remember what time I posted that and don't know the time diff either).
<edit> Okay, it was 1:15am when I posted that reply lol [b]</edit>
http://www.frutzle.com
Snitz Exchange | Do's and Dont's
Edited by - FrutZle on 09 March 2002 20:33:31 |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 13 March 2002 : 18:07:35
|
I'll be heading off in a minute or so, but if I don't post this now I'll forget and I won't be able to find this thread again once I think about it again (okay, enough intro ).
Anyway, I tried this:
<% strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM " & strTablePrefix & "DVD" %> This is the list of DVD's that I own (currently <% =DVD_COUNT %> titles*).
but it doesn't show anything. I know I'm doing something wrong that's completely basic, but I can't figure it out. I also tried Nathan's solution, but that didn't help either (also, no result shown). I know the DB connection works as a couple lines later I have all records showing and sorted by ID...
http://www.frutzle.com
Snitz Exchange | Do's and Dont's |
|
|
Doug G
Support Moderator
USA
6493 Posts |
Posted - 13 March 2002 : 18:40:55
|
There needs to be a bit more code (I haven't tested this)
Your SQL Statement is assigning a column name DVD_COUNT to the results of the COUNT() function. This isn't a ASP variable name, so you need to execute the sql to return a recordset, then get the value out of the recordset.
<% strSql = "SELECT COUNT(ID) AS DVD_COUNT FROM " & strTablePrefix & "DVD" set rstTest = myConn.execute(strSql) DVD_COUNT = rstTest("DVD_COUNT") %>
This is the list of DVD's that I own (currently <% =DVD_COUNT %> titles*).
I just actually read the above posts, this is exactly what Nathan said earlier and should work.
====== Doug G ======
Edited by - Doug G on 13 March 2002 18:43:47 |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 14 March 2002 : 14:13:30
|
Maybe this has something to do with it:
This is the list of DVD's that I own (currently <% =APPLE %> titles*).
Nikkol |
|
|
Roland
Advanced Member
Netherlands
9335 Posts |
Posted - 14 March 2002 : 14:22:39
|
quote:
Maybe this has something to do with it:
This is the list of DVD's that I own (currently <% =APPLE %> titles*).
Nikkol
Yeah, my bad... I put that in there to test something. lol Forgot to take it out again I'm blonde you know
http://www.frutzle.com
Snitz Exchange | Do's and Dont's |
|
|
Nikkol
Forum Moderator
USA
6907 Posts |
Posted - 14 March 2002 : 14:25:32
|
I was gonna tell you to try BANANA instead.
Nikkol |
|
|
Topic |
|