Print Page | Close Window

Get an age

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3215
Printed Date: 29 March 2026 at 5:00pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Get an age
Posted By: aero
Subject: Get an age
Date Posted: 02 June 2003 at 3:05pm

Hi I have this SGL code and it vil show all peble that have an age between 10 and 14 !!

SELECT * FROM db WHERE (age>=10) and (age<=14)

But if i want a function so an user can decide what *agetype he want to see, how can I then make the kode so it show that age I want to see !???

*AGETYPE

10 - 14 Years
15 - 19 Years
20 - 24 Years
25 - 29 Years
30 - 34 Years
35 - 39 Years
and so on !!!!!

Pleas help me !!!




Replies:
Posted By: michael
Date Posted: 02 June 2003 at 3:55pm

Pass it from a form where you have the formvalue passed of e.g. a radio box like
<select name="agerange" value="10 AND 14" type="radio"> and so on then generate the SQL Query in the form:
agerange = Request("agerange")
sql="Select * from db where age between " & agerange

Just add however many radio buttons or if you want a dropdown. This code only work for one value at a time so no multiple....



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: aero
Date Posted: 02 June 2003 at 4:15pm

Okay great !!!

But if I want it to show the persons between 10 and 14 and then have the agerange function !!  how is the code then look like !??



Posted By: michael
Date Posted: 02 June 2003 at 7:28pm

Well if you want to show 10-14 by default and then selectable for other ranges you would do something like...
If agerange = "" THEN

   sql = "Select * from db where age between 10 AND 14"

ELSE

   sql ="Select * from db where age between " & agerange

END IF

'Do you displaying here

....

below all that or wherever you just put the form posting to itself 



-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: aero
Date Posted: 03 June 2003 at 1:03pm

Michael

THX !! but I can get it to work !!

Will U pleas give me a full working script !??

My database !!
db.mdb
age
AID : Auto and Key
Name : Text
Age : Number

Will U make a working script to these informations !??? Pleas !!



Posted By: michael
Date Posted: 03 June 2003 at 1:07pm
Sorry pal, you gotta start yourself and tell us where you get stuck, I basically wrote most of the code already, you just need to extend it. Add all the db code etc and you are done. If you don't know how, there are good tutorials on this site.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: aero
Date Posted: 03 June 2003 at 2:11pm

okay cant write <select name="agerange" value="10 AND 14" type="radio">  shut there be a

<form>
<select name="agerange" value="10 AND 14" type="radio">
</form>

or !?????



Posted By: michael
Date Posted: 04 June 2003 at 8:58am
of course you need to put that into a form. put all the radios in there post it to itself to display required data.

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net