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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using "constant"s in ASP

Status
Not open for further replies.

tharsan

Programmer
Dec 16, 2003
4
0
0
CA
Say I have a page that will have a finite number of ads (0,1,2,3,4,5,...).

Now, I'll query the db and get say 50 ads from it (if there are 50 entries in this db).

Now i would like to be able to show only a certain number of ads at any time, but this number will change (and another ASP script will change it).

so basically i can say

numAds = GET_NUMBER_OF_ADS_SOMEHOW

for(i=0; i < numAds; i++) {
//print ad
}

but how can i keep track of this &quot;NUMBER OF ADS&quot; number?

The possible solutions I've come up with are
- another database table for constants
- using an XML file
- writing to a text file (which i really dont wanna do cuz then i'll have to parse and re-write for every modification, etc.)

which of these would you think is best, or any other way recommended?

Thank You
- Tharsan
 
I usually use a db table but another option I've used is an include file with variable definitions
That way you can still change all of the options in one place. It also gives me a place to write comments about the variables and how they are used, which pages they are used on, why they are set to the current values... that kind of stuff.



Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
try the following, get all ads from the db at once, store them one at a time in a array so you build up a ads array in your ASP. Then you can manipulate this array to show results per page/ results at a time by doing myArray(X) to myArray(Y). If your array doesnt need updating each time you could even store this as an application array. This might not sound very efficient but its worked for me many times before.



x2cms Website Builder - the fast and easy online sitebuilder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top