Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 if Request.Querystring help
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

GhettoDalaiLama
Junior Member

212 Posts

Posted - 25 February 2002 :  00:26:52  Show Profile  Visit GhettoDalaiLama's Homepage  Send GhettoDalaiLama an ICQ Message
OK, I'm trying to make an ASP page that I can link to and use as a image display. Basically, trying to make it so that I can do "http://xyz.com/picture.asp?pic=pic1.jpg" and "picture.asp?pic=pic2.jpg" and so on. Right now, I just have an ASP file that looks like this:


<%
if Request.Querystring("pic") = "pic1.jpg" then %>
<img src="pic1.jpg" border="1">
<% end if
%>
<%
if Request.Querystring("pic") = "pic2.jpg" then %>
<img src="pic2.jpg" border="1">
<% end if
%>


I realize this probably isn't the most efficeint way of doing this (especially if I were to have a couple hundred entries,) but my ASP knowledge is very limited at this point.

ANYWAYS...

My question...

I need to make a default image so that if none of the other Request.Querystring's match, that image is displayed. I'm not sure how or where I would put the else(?) statement so that's why I'm asking. I tried just doing a:


if Request.Querystring("") = "" then %>


statement but then that particular pic always is displayed.

Thanks to whomever can figure this out.

Scott

-------------------------
http://forums.akghetto.com
OS: Win2000 Adv Server SP2
Webserver: IIS 5.0
Snitz: 3.3.03
MySQL: 3.23.40
ODBC Driver: MySQL v.2.50.37.00 - 20.Apr.01

Edited by - GhettoDalaiLama on 25 February 2002 00:28:09

Cyber Paladin
New Member

55 Posts

Posted - 25 February 2002 :  00:43:45  Show Profile  Visit Cyber Paladin's Homepage
<%
SELECT CASE Request.Querystring("pic")
CASE "pic1.jpg"
response.write "<img src=""pic1.jpg"" border=""1"">"

CASE "pic2.jpg"
response.write "<img src=""pic2.jpg"" border=""1"">"

CASE ELSE
response.write "<img src=""pic3.jpg"" border=""1"">"

END SELECT
%>

- "Profanity is the one language all programmers understand."
- "Always remember: Amatuers may have built the Ark, but professionals built the Titanic."
- "I'd say that's my 2 cents but then I would be coining a phrase." (insert groan here)

Edited by - Cyber Paladin on 25 February 2002 00:44:17
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 25 February 2002 :  00:47:12  Show Profile
You can use a Select Case statement:
Select Case Request.QueryString("pic")
Case "pic1.jpg"
Response.Write "<img src=""pic1.jpg"" border=""1"">"
Case "pic2.jpg"
Response.Write "<img src=""pic1.jpg"" border=""1"">"
...
...
Case else
Response.Write "<img src=""defaultpic.jpg"" border=""1"">"
End Select
If your images are named pic1, pic2, etc., you could change your url to something like: http://xyz.com/picture.asp?pic=1 and put the url like this:
x = Request.QueryString("pic")

<img src="pic<%=x%>.jpg" border="1">
But that will only work if your pics files are numbered. And your default picture would be called pic.jpg.

Of course I was beaten to it.

«------------------------------------------------------»
Read the Do's and Don'ts before you post for help
«------------------------------------------------------»


Edited by - Davio on 25 February 2002 00:49:14
Go to Top of Page

Nathan
Help Moderator

USA
7664 Posts

Posted - 25 February 2002 :  00:54:45  Show Profile  Visit Nathan's Homepage
quote:
Case else
Response.Write "<img src=""defaultpic.jpg"" border=""1"">"


quote:
And your default picture would be called pic.jpg.


 Nathan Bales - Romans 15:13
---------------------------------

Snitz Exchange | Mod Resource
Go to Top of Page

GhettoDalaiLama
Junior Member

212 Posts

Posted - 25 February 2002 :  01:05:54  Show Profile  Visit GhettoDalaiLama's Homepage  Send GhettoDalaiLama an ICQ Message
Hey thanks alot you two. Works like a charm.

-------------------------
http://forums.akghetto.com
OS: Win2000 Adv Server SP2
Webserver: IIS 5.0
Snitz: 3.3.03
MySQL: 3.23.40
ODBC Driver: MySQL v.2.50.37.00 - 20.Apr.01
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 25 February 2002 :  01:12:39  Show Profile
Nathan, those were 2 different examples.

«-------------------------------------------------»
Read the Do's and Don'ts before you post for help
«-------------------------------------------------»
Go to Top of Page

GhettoDalaiLama
Junior Member

212 Posts

Posted - 02 March 2002 :  21:18:25  Show Profile  Visit GhettoDalaiLama's Homepage  Send GhettoDalaiLama an ICQ Message
OK, now Davio...

you said that I could also do a
quote:

x = Request.QueryString("pic")
<img src="pic<%=x%>.jpg" border="1">



but I've ran into another problem...

If someone puts text in as the QueryString then we get an error.

Right now I have :


strWhatPic = Request.QueryString("pic")


if strWhatPic = "" then
strWhatPic = 0
end if



(green part put in so if left blank it's replaced with 0 )

My question is how can I make it so that if anything besides a number is put in as the QueryString, it can set the strWhatPic to 0?

Thanks again.

-------------------------
http://forums.akghetto.com
OS: Win2000 Adv Server SP2
Webserver: IIS 5.0
Snitz: 3.3.03
MySQL: 3.23.40
ODBC Driver: MySQL v.2.50.37.00 - 20.Apr.01
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 02 March 2002 :  21:42:55  Show Profile
strWhatPic = Request.QueryString("pic")


if strWhatPic = "" or IsNumeric(strWhatPic) = False then
strWhatPic = 0
end if
You can try that.

«-------------------------------------------------»
Read the Do's and Don'ts before you post for help
«-------------------------------------------------»
Go to Top of Page

GhettoDalaiLama
Junior Member

212 Posts

Posted - 02 March 2002 :  22:22:43  Show Profile  Visit GhettoDalaiLama's Homepage  Send GhettoDalaiLama an ICQ Message
David,

Once again, THANK YOU!

-------------------------
http://forums.akghetto.com
OS: Win2000 Adv Server SP2
Webserver: IIS 5.0
Snitz: 3.3.03
MySQL: 3.23.40
ODBC Driver: MySQL v.2.50.37.00 - 20.Apr.01
Go to Top of Page

Davio
Development Team Member

Jamaica
12217 Posts

Posted - 03 March 2002 :  15:59:11  Show Profile
You're Welcome.

«-------------------------------------------------»
Read the Do's and Don'ts before you post for help
«-------------------------------------------------»
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.35 seconds. Powered By: Snitz Forums 2000 Version 3.4.07