Fixed search - it actually works now!
This commit is contained in:
parent
6c0e88f4e7
commit
b1664f0af3
@ -1,6 +1,6 @@
|
|||||||
# Meme Machine
|
# Meme Machine
|
||||||
|
|
||||||
## Current Version: v0.3.5-beta
|
## Current Version: v0.3.6-beta
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
@ -16,6 +16,11 @@ Users are then able to browse the memes using the categories, and in future vers
|
|||||||
|
|
||||||
## Changelog
|
## 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
|
### v0.3.5-beta - April 7, 2016
|
||||||
|
|
||||||
- Categories are now a drop-down box rather than an incoherent table
|
- Categories are now a drop-down box rather than an incoherent table
|
||||||
|
@ -20,26 +20,22 @@ echo '<h1>Meme Machine</h1>';
|
|||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
|
|
||||||
$term = $_POST['term'];
|
$words = $_POST['term'];
|
||||||
|
|
||||||
|
|
||||||
$tokens = explode(' ', $term);
|
$parts=explode(" ",trim($words));
|
||||||
$tokens = array_map(
|
$clauses=array();
|
||||||
function($term) {
|
foreach ($parts as $part){
|
||||||
return mysqli_real_escape_string(trim($term));
|
$clauses[]="'%" . $part . "%'";
|
||||||
},
|
}
|
||||||
$tokens
|
$clause .= implode(' OR ' ,$clauses);
|
||||||
);
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM memes WHERE name LIKE '$term";
|
$sql = "SELECT * FROM memes WHERE name LIKE $clause OR category LIKE $clause";
|
||||||
$sql .= implode("%' or name LIKE '%", $tokens) . "'";
|
if(isset($_POST['search']) && $words){
|
||||||
|
echo "You searched for: " . $words . "<br />";
|
||||||
if(isset($_POST['search']) && $term){
|
|
||||||
echo "You searched for: " . $term . "<br />";
|
|
||||||
|
|
||||||
$result = mysqli_query($conn, $sql);
|
$result = mysqli_query($conn, $sql);
|
||||||
|
|
||||||
echo $sql;
|
|
||||||
if (mysqli_num_rows($result) > 0) {
|
if (mysqli_num_rows($result) > 0) {
|
||||||
while($row = mysqli_fetch_assoc($result)) {
|
while($row = mysqli_fetch_assoc($result)) {
|
||||||
$count++;
|
$count++;
|
||||||
@ -65,8 +61,8 @@ echo '<h1>Meme Machine</h1>';
|
|||||||
<a href="./">Back</a>
|
<a href="./">Back</a>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
echo '<br>';
|
||||||
|
echo '<a href="./">Back</a>';
|
||||||
echo '</body>';
|
echo '</body>';
|
||||||
echo '</html>';
|
echo '</html>';
|
||||||
?>
|
?>
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
<!--
|
||||||
|
The Meme Machine - An open source image databasing system
|
||||||
|
A project by Taylor Courage (http://taylorcourage.net)
|
||||||
|
Latest Release: v0.3.6-beta (April 7, 2016)
|
||||||
|
-->
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Meme Machine</title>
|
<title>Meme Machine</title>
|
||||||
@ -98,6 +103,6 @@
|
|||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
<h6>Meme Machine v0.3.5-beta</h6>
|
<h6>Meme Machine v0.3.6-beta</h6>
|
||||||
</div>
|
</div>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user