Posted By


mattneary on 01/22/11

Tagged


Statistics


Viewed 800 times
Favorited by 0 user(s)

MySQL Search/Category Filter


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. $query = $search ?
  2. ( !$cat ?
  3. "SELECT * FROM games WHERE name LIKE '%".$search."%'" :
  4. "SELECT * FROM games WHERE category='".$cat."' AND name LIKE '%".$search."%'"
  5. ):
  6. ( $cat ?
  7. "SELECT * FROM games WHERE category='".$cat."'" :
  8. "SELECT * FROM games WHERE name='N/A'"
  9. );
  10. basic_connect($query);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.