'; $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 ''; echo ''; if (mysqli_num_rows($result) > 0) { while ($row = $result->fetch_array()){ echo ''; } } else { echo 'No results found!
'; } echo '
Pop #Pop NameDate AddedPop Collection
' . $row['popno'] . '' . $row['popname'] . '' . $row['inserteddate'] . '' . $row['popcollection'] . '

Click here to search again.
'; } else { echo 'Please search for a Funko Pop name!
'; echo '
Funko Pop name to search for:

'; //echo 'Funko Pop number to search for:
'; echo '


'; $sqlfpc = "SELECT DISTINCT `popcollection`.`popcollectionid`, `popcollection`.`popcollection` FROM (popcollection INNER JOIN pops ON popcollection.popcollectionid = pops.popcollectionid) WHERE `pops`.`userid` = $userid ORDER BY popcollection.popcollection ASC"; if (!$result2 = $con->query($sqlfpc)){ die ('There was an error running the query [' . $con->error . ']'); } echo 'Or find all Funko Pops by collection:
'; } } include_once ('footer.php'); ?>