Query Strings for Idiots W-O-G 3/16/00 Easy Free NT Web Hosting, Free ASP Hosting, Free Web hosting, Free Hosting - DomainDLX
    

    Home
    Registration
    FAQs
    Terms of service
    Contact us

    Learn ASP
    Databases
    Articles

If you are reading this article then I assume you don't have much ASP experience. Well a query string is the text in a URL or "address" after the ? (hence, the name QUERY string). You might have seen them when using a search engine, because query strings show up when you submit data using the GET method instead of POST. Query strings allow you to pass variables and data to a page. In the query string there are variable names followed by = followed by the data. If there are multiple variables, then they will be separated by an Ampersand &.

Query strings allow for you to easily pass along data or allow you to dynamically choose what content shows up by using IF/THEN statements. To get the data in a query string, you use the Request.QueryString() method with the variable name inside the parenthesis () and wrapped in quotes "". Just look at the example below.

example.asp

------------------------------------------
<%
mydata = Request.QueryString("myname")
Response.Write "Your name is " & mydata
%>

The above example would produce Your name is Mark when you surf to example.asp?myname=Mark. You could also do this:

begin.asp
------------------------------------------
<FROM method="get" action="example.asp">
<input type=text value="mark" name="myname">
<input type=submit value="try me">
</FORM>


example.asp
------------------------------------------
<%
mydata = Request.QueryString("myname")
Response.Write "Your name is " & mydata
%>

Now try it out:

Now you should have a good idea of what a query string is.