Skip to content

Commit

Permalink
simple mysql search using like
Browse files Browse the repository at this point in the history
  • Loading branch information
andreisavu committed Apr 27, 2009
1 parent 18e3994 commit 21107b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions index.py
Expand Up @@ -35,9 +35,15 @@ def GET(self):

class do_search:
def GET(self):
input = web.input(q='')
input = web.input(q=None)
q = input.q
files = db.select('ms_files', order='date desc', limit=10)
files = []
if q:
pq = [t.strip() for t in q.split(' ') if len(t.strip())!=0]
pq = '%' + '%'.join(pq) + '%'
files = db.query('select * from ms_files where filename like $q', vars={'q':pq})
else:
q = ''
return render.search(files, query=q, title='Search')

class do_upload_error:
Expand Down
6 changes: 4 additions & 2 deletions templates/search.html
Expand Up @@ -22,7 +22,7 @@
$$('#tabs').tabs();
});
</script>

<br />
$for file in files:
<b>Original:</b> $file.filename<br />
<b>Player:</b>
Expand All @@ -32,5 +32,7 @@
</object>
<hr />

$if not files and query:
<h3>No results found. Try another query.</h3>


<br />

0 comments on commit 21107b4

Please sign in to comment.