This question already has an answer here:
I'm trying to create a webpage that shows me the contents of an SQL-Database. This works, but now i'm creating a search option that allows for filtering.
I can't seem to get the superglobal $_GET
to work though, and I always get his error:
Parse error: syntax error, unexpected '$_GET' (T_VARIABLE) HTML/PHP code:
<header>
<div id="divSearchBar">
<form name="SearchBar" method="get" action="index.php">
<input type="text" name="txtSearchBar"/>
<input type="submit" value="Search"/>
<input type="submit" name="sbmAddItem" value="Add Item"/>
</form>
</div>
</header>
<main>
<?php
include_once "Repository.php";
$r = new Repository();
$tmp = "";
if (isset $_GET["txtSearchBar"])
{
$tmp = $_GET["txtSearchBar"];
}
$myItems = $r->GetItems(tmp);
for($i=0;$i<count($myItems);$i++)
{
print '<div id="divGen"><p id="pGen">' . $myItems[$i]->Item . '</p><p id="pGen2">' . $myItems[$i]->Category . "</p></div>";
}
?>
</main>
</div>