All pastes #252117 Raw Edit

Mine

public text v1 · immutable
#252117 ·published 2006-11-19 02:33 UTC
rendered paste body
<?php

//Grab the values from $_GET.
$config = $_GET;

//Clean the strings.
foreach ($config as &$value)
	$value = mysql_real_escape_string($value);

//Create the query with no filters, except to eliminate anything I've given a negative ID:
$query = 'SELECT * FROM wowquests WHERE ID > 0';

//
// Filtering
//

//Did the user specify a Name filter?
if ($config['filterName'] and $config['filterName'] != "Ignore")
{

	//Append name filtering to the query:
	$query .= ' AND Name LIKE "%' .$config['filterName'] .'%"';

}

//Did the user specify a Minimum Level filter?
if ($config['filterMinLvl'] and $config['filterMinLvl'] != "Ignore")
{

	//Append name filtering to the query:
	$query .= ' AND Level >=' .$config['filterMinLvl'] .'';

}

//Did the user specify a Maximum Level filter?
if ($config['filterMaxLvl'] and $config['filterMaxLvl'] != "Ignore")
{

	//Append name filtering to the query:
	$query .= ' AND Level <=' .$config['filterMaxLvl'] .'';

}


//
// Sorting
//

//Was the first sort specified?
if ($config['sortBy'] and $config['sortBy'] != "Ignore")
{
	//Append proper sorting to the query:
	$query .= ' ORDER BY ' .$config['sortBy'];
	
}

//Was a third sort specified?
if ($config['sortBy3'] and $config['sortBy3'] != "Ignore")
{
	
	//Append proper sorting to the query:
	$query .= ' ORDER BY ' .$config['sortBy3'];

}


//Were any sorts filled out?
if (($config['sortBy'] and $config['sortBy'] != "Ignore") or ($config['sortBy2'] and $config['sortBy2'] != "Ignore") or ($config['sortBy3'] and $config['sortBy3'] != "Ignore"))
{

	//Append a name sorting at the end:
	$query .= ', Name';

}

else
{

	//Append a name sorting at the end:
	$query .= ' ORDER BY Name';

}

?>