PDA

View Full Version : Variable SQL


rah111
07-03-2002, 03:06 AM
Hi there.

I currently have the following code in Test.htm:

<a href="Connect.asp" target="frame2.htm"><img ...></a>

Then Connect.asp is called which has the following SQL command:

SELECT Field1, Field2, Field3 FROM Table1 WHERE Group=6

This works fine and frame2.htm is dynamically updated with the data from the fields in Table1 where the field Group equals 6.

My problem is this:

The value of Group can be 1,2,3,4,5,6,7,8,9 or 10.

I would like 10 images ({Group 1},{Group 2}, ... , {Group 10}) with <a href>...</a> links to Connect.asp but for each of them to pass a variable "number" to Connect.asp.

Then, hopefully, I could adjust the SQL code to read:

SELECT Field1, Field2, Field3 FROM Table1 WHERE Group=number

Failing this I'd have to create Connect1.asp, Connect2.asp etc.

Can someone please tell me how I can do this?

Thanks in advance.

Russell.

glenngv
07-03-2002, 03:33 AM
you should have posted it on ASP forum.

anyway, here's the answer:

if you want it to be an htm file, you can hardcode it 10 times:

<a href="Connect.asp?grp=1" target="frame2.htm"><img..></a>
<a href="Connect.asp?grp=2" target="frame2.htm"><img..></a>
......
<a href="Connect.asp?grp=10" target="frame2.htm"><img..></a>

or you can make it an asp file looping 10 times (I assume you know how to do it )

in your next page:

grp=request.querystring("grp")
if grp="" then grp=1
strSQL="SELECT Field1, Field2, Field3 FROM Table1 WHERE Group=" & grp
'your query execution here

rah111
07-03-2002, 03:59 AM
Thanks Glenn.

Will post any such question to an ASP forum from now on.

Russell.