diff --git a/README.md b/README.md index 2f966c8..6c56f5b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Meme Machine -## Current Version: v0.3.5-beta +## Current Version: v0.3.6-beta ## Overview @@ -16,6 +16,11 @@ Users are then able to browse the memes using the categories, and in future vers ## Changelog +### v0.3.6-beta - April 7, 2016 + +- Fixed critical issue where searches wouldn't work +- Added fancy new details section on landing page + ### v0.3.5-beta - April 7, 2016 - Categories are now a drop-down box rather than an incoherent table diff --git a/browse/query.php b/browse/query.php index edb91f5..8ae1fca 100644 --- a/browse/query.php +++ b/browse/query.php @@ -20,26 +20,22 @@ echo '

Meme Machine

'; } else { } - $term = $_POST['term']; + $words = $_POST['term']; - $tokens = explode(' ', $term); - $tokens = array_map( - function($term) { - return mysqli_real_escape_string(trim($term)); - }, - $tokens - ); + $parts=explode(" ",trim($words)); + $clauses=array(); + foreach ($parts as $part){ + $clauses[]="'%" . $part . "%'"; + } + $clause .= implode(' OR ' ,$clauses); - $sql = "SELECT * FROM memes WHERE name LIKE '$term"; - $sql .= implode("%' or name LIKE '%", $tokens) . "'"; - - if(isset($_POST['search']) && $term){ - echo "You searched for: " . $term . "
"; + $sql = "SELECT * FROM memes WHERE name LIKE $clause OR category LIKE $clause"; + if(isset($_POST['search']) && $words){ + echo "You searched for: " . $words . "
"; $result = mysqli_query($conn, $sql); - echo $sql; if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { $count++; @@ -65,8 +61,8 @@ echo '

Meme Machine

'; Back '; +echo 'Back'; echo ''; echo ''; ?> diff --git a/index.php b/index.php index bc657ef..7fd933c 100644 --- a/index.php +++ b/index.php @@ -1,3 +1,8 @@ + Meme Machine @@ -98,6 +103,6 @@


-
Meme Machine v0.3.5-beta
+
Meme Machine v0.3.6-beta