Return to Snippet

Revision: 39902
at January 22, 2011 09:09 by mattneary


Initial Code
$query = $search ?
		( !$cat ? 
			"SELECT * FROM games WHERE name LIKE '%".$search."%'" :
			"SELECT * FROM games WHERE category='".$cat."' AND name LIKE '%".$search."%'"
		):
		( $cat ?
			"SELECT * FROM games WHERE category='".$cat."'" :
			"SELECT * FROM games WHERE name='N/A'"
		);
basic_connect($query);

Initial URL
http://mneary.info/home/search.php

Initial Description
I thought this was pretty elegant code and wanted to share it with anyone who found it useful.

Initial Title
MySQL Search/Category Filter

Initial Tags
form, mysql, php, search

Initial Language
PHP