<form action="" method="post"><input type="text" name="name" placeholder="Enter a Item"></input>  <input type="submit" value="Search"></input></form>

<?php
if(!isset($_GET['online'])){
	$_GET['online']='false';
}
if($_GET['online']=='true'){
	echo '
	<div class="form-check form-switch">
	<input class="form-check-input" type="checkbox" id="flexSwitchCheckChecked" checked onclick=window.location="?p=bazaar">
	<label class="form-check-label" for="flexSwitchCheckChecked">Bazaar Online</label>
	</div>';
}
else{
	echo '
	<div class="form-check form-switch">
	<input class="form-check-input" type="checkbox" id="flexSwitchCheckDefault" onclick=window.location="?p=bazaar&online=true">
	<label class="form-check-label" for="flexSwitchCheckDefault">All Bazaar</label>
	</div>';
}
echo '<table class="table table-hover">
<tr class=table-primary><td>Item</td><td>Player</td><td>Gil</td><td>Quantity</td></tr>';
if(isset($_POST['name'])){
	$_POST['name']=$_POST['name'];
	$_POST['name']=str_replace(" ","_",$_POST['name']);
}
if (!isset($_POST['name']))
{
}
elseif(strlen($_POST['name'])<='3')
{
	echo getPanel("warning","Error","You Must enter more than 3 characters");
}
elseif(getItemList($_POST['name'])=='empty')
{
	echo getPanel("warning","Error","No Items Found");
}
else
{
	$name = $_POST['name'];
	$item = getBazaarList($name);
	foreach ($item as $items){
		if($_GET['online']=='true'){
			if(isCharOnline($items['charid'])=='TRUE'){
				echo '<tr><td><a href="?p=bazaar&id='.$items['itemid'].'">'.ucwords(str_replace('_',' ',$items['sortname'])).'</a></td><td><a href=?p=characters&id='.$items['charid'].'>'.getCharacterName($items['charid']).'</a></td><td>'.$items['bazaar'].'</td><td>'.$items['quantity'].'</td></tr>';
			}
			else{
			}
		}
		else{
			echo '<tr><td><a href="?p=bazaar&id='.$items['itemid'].'">'.ucwords(str_replace('_',' ',$items['sortname'])).'</a></td><td><a href=?p=characters&id='.$items['charid'].'>'.getCharacterName($items['charid']).'</a></td><td>'.$items['bazaar'].'</td><td>'.$items['quantity'].'</td></tr>';
		}
	}
	echo '</table>';
}

if(!isset($_POST['name'])){
	/*
	$all = getAllBazaar();
	foreach ($all as $items){
		if($_GET['online']=='true'){
			if(isCharOnline($items['charid'])=='TRUE'){
				echo '<tr><td><a href="?p=bazaar&id='.$items['itemid'].'">'.ucwords(str_replace('_',' ',$items['sortname'])).'</a></td><td><a href=?p=characters&id='.$items['charid'].'>'.getCharacterName($items['charid']).'</a></td><td>'.$items['bazaar'].'</td><td>'.$items['quantity'].'</td></tr>';
			}
			else{
			}
		}
		else{
			echo '<tr><td><a href="?p=bazaar&id='.$items['itemid'].'">'.ucwords(str_replace('_',' ',$items['sortname'])).'</a></td><td><a href=?p=characters&id='.$items['charid'].'>'.getCharacterName($items['charid']).'</a></td><td>'.$items['bazaar'].'</td><td>'.$items['quantity'].'</td></tr>';
		}
	}
	*/
	echo '</table>';
}