Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would you pass through ">=" in the querystring?

I would like to pass some operators through as querystring parameters so that I can convert them, along with a value into an SQL query. The idea would be to let the querystring parameters dictate wether the page returns search results where prices are equal to, greater than or equal to, greater than, less than or less than or equal to as follows:

=, >=, >, < and <=

I'm not sure what the best practise is for passing these operators through is, could anybody help me out? Would you pass through ascii codes or simply text like e, gte, gt, lt, lte and then convert them on results page that builds the query?

Thanks guys!

like image 426
Sgt Beardy Avatar asked May 28 '11 15:05

Sgt Beardy


People also ask

How do you pass a QueryString?

To pass in parameter values, simply append them to the query string at the end of the base URL. In the above example, the view parameter script name is viewParameter1.

How do I pass more than one parameter in a URL?

URL parameters are made of a key and a value, separated by an equal sign (=). Multiple parameters are each then separated by an ampersand (&).

What do you mean by QueryString explain with example?

A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.

What is a QueryString parameter?

What are query string parameters? Query string parameters are extensions of a website's base Uniform Resource Locator (URL) loaded by a web browser or client application. Originally query strings were used to record the content of an HTML form or web form on a given page.


2 Answers

As user Kon said, use HttpServerUtility.UrlEncode. I've once written a tiny little class to simplify working with query strings so that I do not have to call Server.UrlEncode.

As a side note, keep an eye on SQL injection aka Little Bobby Tables:

Little Bobby Tables(Source)

like image 69
2 revs Avatar answered Sep 22 '22 07:09

2 revs


Server.UrlEncode

like image 27
Kon Avatar answered Sep 19 '22 07:09

Kon