I am currently working on a kind of "list", where users can put in different data to create a kind of log for various activities, specifically in simulators. I got the basics of it layed down and in fact fully up and running, however, theres still one component, rather critical to me. This being, the users ALSO being able to search for the author of the route. So look at it like this:
Name - Distance - Date
Bob - 100km - 01-01-2015
Jones - 200km - 01-01-2015
Jones - 250km - 01-01-2015
This, is essentially the list the users would see. If the users put in "Jones", they should only see the result of Jones. However, I cannot get this to work.
The code I am currently using to try to achieve the "filter" :
<div class="filters">
<ul>
<li>
<form method="POST" action="index.php?category=trucking">
<input type="text" name="filterName" />
<input type="submit" name="submit" label="Search for Author" />
</form>
</li>
<li>
<a href="index.php?category=addEntryFT"><b>Add a entry</b></a>
</li>
</ul>
</div>
<div class="results">
<?php
// Get from database
if(isset($_POST['submit'])) {
$filterName = $_POST['filterName'];
$result = mysqli_query($anslutning, "SELECT * FROM tblLogs WHERE category = 'trucking' AND author LIKE '$filterName'");
}
?>
So first I create a form where the user puts in a author, and whatever they put in, should apply. Two issues :
1) The form makes the page redirect to the previous page, and 2) it doesn't filter out anything
So in its very basic, pretty much a search bar that points to a database and checks the records there, and this is all I have to come with, which obviously does not work.