Posts Tagged ‘query string’

What is a query string?

Monday, January 18th, 2010

This post goes out to all of those people out there who have seen all of those numbers and letters jumbled up at the end of a URL that really do not make any sense. This is the query string, and it makes sense to web browsers! The query string always starts with a ? mark after the URL. After the question mark a query string has a parameter and value, e.g. color=Blue. This is a way for a link to call out to a web page that has .

Example:


http//scottlassiter.com/index.php?color=blue

This parameter will be sent through the query string and intercepted by a code within a web page that is usually hidden in the view source option. The web receiving web page has parameters that look for a certain parameter, e.g. color, and then parses what the value of that parameter is, e.g. blue.

So if I have a page that is looking for a Query String parameter of color=blue, then I may have a function to list all of the logos I have created that are classified as blue.

Each URL can have several parameters passed through the query string. To add another parameter, you add an ampersand & followed by the next parameter.

Example:


http//scottlassiter.com/index.php?color=blue&logo=3

This example would be calling for logo=3. In my code I could have a logo that is listed as 3, so that logo would show.

There are many ways to use the parameters and their values to extract specific data from a web page. Query strings give an easy way for links to communicate to websites to pull information. Next time you are on Facebook or twitter, check out the query string, it will show all kinds of interesting values. Some will look to make sense and others not. Hopefully this helps you understand the web a little more!

How to refresh XML in Flash files

Monday, December 21st, 2009

I have recently been working with loading XML documents in Flash files. This is great technology. The ability to feed dynamic XML data into flash is very powerful and will give you (the designer) a lot of creative freedom. Recently I was using a test XML document in my development environment and altered my XML file. The problem was that every time I re-loaded the file, I was getting the exact same output.

Here is the code that I was using first. Notice that is the same URL.

xmlLoader.load(new URLRequest ("myXMLfile.xml");

Since this file was already cached, it would load over and over again in my output window.

How did I get around this? I added a random query string to the end of URL. I did this by using the Math.random() function built into Flash.

xmlLoader.load(new URLRequest ("myXMLfile.xml?num=" + (Math.random() * 500)));

This little snipped of code will add a random number between 1 and 500 to the end of your query string. You can make the 500 whatever number you want, however I recommend keeping it under 1000.

Hope this helps you!