';
$searchtype = (isset($_POST['stype']) ? $_POST['stype'] : $_GET['search']);
$searchtype = mysqli_real_escape_string($con, $searchtype);
$searchname = (isset($_POST['searchname']) ? $_POST['searchname'] : null);
$searchname = mysqli_real_escape_string($con, $searchname);
$searchcollection = (isset($_POST['collectionid']) ? $_POST['collectionid'] : $_GET['cid']);
$searchcollection = mysqli_real_escape_string($con, $searchcollection);
if (!empty($searchname) || !empty($searchcollection)) {
if ($searchtype == "name") {
$sqlsearch = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `popname` LIKE '%$searchname%' AND `userid` = $userid ORDER BY popcollection.popcollection, pops.popno ASC";
$sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `popname` LIKE '%$searchname%' AND `userid` = $userid";
} else if ($searchtype == "group") {
$sqlsearch = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid ORDER BY popno ASC";
$sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid";
} else {
echo 'No search type defined, please try again!';
include_once ('footer.php');
exit();
}
if (!$result = $con->query($sqlsearch)){
die ('There was an error running the query [' . $con->error . ']');
}
$count = mysqli_query($con, $sqlcount);
$row3 = mysqli_fetch_array($count);
if ($row3['count'] > 1) {
echo 'There are ' . $row3['count'] . ' Funko Pops in the search results
Click the Pop # to edit the data
';
} else {
echo 'There is ' . $row3['count'] . ' Funko Pop in the search results
Click the Pop # to edit the data
';
}
echo '
| Pop # | Pop Name | Date Added | Pop Collection |
| ' . $row['popno'] . ' | ' . $row['popname'] . ' | ' . $row['inserteddate'] . ' | ' . $row['popcollection'] . ' |