Yet another PHP based Funko Pop collection tracker, about as bare bones as you can get, but it's functional.
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

63 linhas
3.9 KiB

  1. <?php
  2. $pagetitle = "Funko Pop Search";
  3. include_once ('header.php');
  4. if (isset($_SESSION['userid']) && ($_SESSION['username'])) {
  5. echo '<BODY onLoad="document.funkosearch.searchname.focus()">';
  6. $searchtype = (isset($_POST['stype']) ? $_POST['stype'] : null);
  7. $searchtype = mysqli_real_escape_string($con, $searchtype);
  8. $searchname = (isset($_POST['searchname']) ? $_POST['searchname'] : null);
  9. $searchname = mysqli_real_escape_string($con, $searchname);
  10. $searchcollection = (isset($_POST['collectionid']) ? $_POST['collectionid'] : null);
  11. $searchcollection = mysqli_real_escape_string($con, $searchcollection);
  12. if (!empty($searchname) || !empty($searchcollection)) {
  13. if ($searchtype == "name") {
  14. $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";
  15. $sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `popname` LIKE '%$searchname%' AND `userid` = $userid";
  16. } else if ($searchtype == "group") {
  17. $sqlsearch = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid ORDER BY popno ASC";
  18. $sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid";
  19. } else {
  20. echo 'No search type defined, please try again!';
  21. include_once ('footer.php');
  22. exit();
  23. }
  24. if (!$result = $con->query($sqlsearch)){
  25. die ('There was an error running the query [' . $con->error . ']');
  26. }
  27. $count = mysqli_query($con, $sqlcount);
  28. $row3 = mysqli_fetch_array($count);
  29. if ($row3['count'] > 1) {
  30. echo 'There are ' . $row3['count'] . ' Funko Pops in the search results<BR />Click the Pop # to edit the data<BR />';
  31. } else {
  32. echo 'There is ' . $row3['count'] . ' Funko Pop in the search results<BR />Click the Pop # to edit the data<BR />';
  33. }
  34. echo '<TABLE BORDER="0">';
  35. echo '<TR><TD>Pop #</TD><TD>Pop Name</TD><TD>Date Added</TD><TD>Pop Collection</TD></TR>';
  36. if (mysqli_num_rows($result) > 0) {
  37. while ($row = $result->fetch_array()){
  38. echo '<TR><TD><A HREF="edit.php?id=' . $row['funkoid'] . '">' . $row['popno'] . '</A></TD><TD>' . $row['popname'] . '</TD><TD>' . $row['inserteddate'] . '</TD><TD>' . $row['popcollection'] . '</TD></TR>';
  39. }
  40. } else {
  41. echo 'No results found!<BR />';
  42. }
  43. echo '</TABLE><BR />Click <A HREF="search.php" CLASS="navlink">here</A> to search again.<BR />';
  44. } else {
  45. echo 'Please search for a Funko Pop name! <BR />';
  46. echo '<FORM ACTION="search.php" METHOD="POST" NAME="funkosearch">Funko Pop name to search for: <INPUT TYPE="TEXT" NAME="searchname" SIZE="30"><BR /><BR />';
  47. //echo 'Funko Pop number to search for: <INPUT TYPE="NUMBER" NAME="searchno" MIN="1" MAX="9999"><BR />';
  48. echo '<INPUT TYPE="HIDDEN" NAME="stype" VALUE="name"><INPUT TYPE="SUBMIT" VALUE="Search for a Pop"></FORM><BR /><BR />';
  49. $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";
  50. if (!$result2 = $con->query($sqlfpc)){
  51. die ('There was an error running the query [' . $con->error . ']');
  52. }
  53. echo 'Or find all Funko Pops by collection: <FORM ACTION="search.php" METHOD="POST"><SELECT NAME="collectionid">';
  54. while ($row2 = $result2->fetch_array()){
  55. $pcid = $row2['popcollectionid'];
  56. $pcname = $row2['popcollection'];
  57. echo '<OPTION VALUE="' . $pcid . '">' . $pcname . '</OPTION>';
  58. }
  59. echo '</SELECT><INPUT TYPE="HIDDEN" NAME="stype" VALUE="group"><INPUT TYPE="SUBMIT" VALUE="List group"></FORM>';
  60. }
  61. }
  62. include_once ('footer.php');
  63. ?>