All pastes #385077 Raw Edit

Untitled

public text v1 · immutable
·published 2007-03-07 16:08 UTC
rendered paste body
		if(empty($Search))
		{
			// For each of the five priority levels.
			for($z=1; $z<6; $z++)
			{
				if(is_numeric($CategoryPassedBack))
				{
					// Firstly check if there are is machinery within the table with the priority level $z.
					$query = sprintf("SELECT * FROM Machinery WHERE Priority=$z AND Category=%s",
						quote_smart($CategoryPassedBack));

					// Count the number of machines within the table with a priority level $z.
					$num = mysql_num_rows(mysql_query($query));

					// If there are no machines with priority level $z, do not attempt to display them.
					// $query1 is set to blank.
					// Errors are displayed when attempting to display machines with a priority level $z when there isn't a machine with priority level $z in the table.
					if($num == 0)
					{
						$query1="";
					}
					else
					{
						// Select all itesm from the Machinery-Category which was passed from the previous page.
						$query1 = sprintf("SELECT * FROM Machinery WHERE Category = $CategoryPassedBack AND Priority=$z ORDER BY Make ASC LIMIT %s, %s", quote_smart($from), quote_smart($max_results));

						$x = mysql_num_rows(mysql_query($query));


						echo "Priority " . $z . ". Rows: " . $x . "<br />";

//						$z = $z - $x;

						display_machinery($query1);
					}
				}
				// A Machinery-Category was not passed from the previous page.
				else
				{
					$query = "SELECT * FROM Machinery WHERE Priority=$z";

					$num = mysql_num_rows(mysql_query($query));

					if($num == 0)
					{
						$query1="";
					}
					else
					{
						// Select all items in the database.
						$query1 = sprintf("SELECT * FROM Machinery WHERE Priority=$z ORDER BY Make ASC LIMIT %s, %s", quote_smart($from), quote_smart($max_results));
						$x = mysql_num_rows(mysql_query($query));

						echo "Priority " . $z . ": Rows: " . $x . "<br />";

//						$z = $z - $x;

						display_machinery($query1);
					}
				}

			}
		}
		else
		{
			// Select all rows where Make, Model and Specifics are like the string that the user searched for.
			$query = sprintf("SELECT * FROM Machinery WHERE (Make LIKE %s) OR (Model LIKE %s) OR (Specifics LIKE %s)",
				quote_smart("%" . $Search . "%"),
				quote_smart("%" . $Search . "%"),
				quote_smart("%" . $Search . "%"));

			$result = mysql_query($query);

			$num = mysql_num_rows($result);

			if($num == 0)
			{
				echo "<tr><td colspan='7' align='center' style='padding-top:20px;'>Search Returned No Results.<br />Click <a href='used_home.php'>Here</a> To Return Home.</td></tr>";
				$query1="";
			}
			else
			{
				// Select all items in the database.
				$query1 = sprintf("SELECT * FROM Machinery WHERE (Make LIKE %s) OR (Model LIKE %s) OR (Specifics LIKE %s) ORDER BY Make ASC",
					quote_smart("%" . $Search . "%"),
					quote_smart("%" . $Search . "%"),
					quote_smart("%" . $Search . "%"));

				display_machinery($query1);
			}

		}