Guest User

Untitled

a guest
Aug 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. if ($result->num_rows > 0) {
  2. while($row = $result->fetch_assoc()) {
  3.  
  4. $product[] = [
  5. "ID" => $row["ID"],
  6. "Name" => $row["Productname"],
  7. "Price" => $row["Pricetag"],
  8. "Supply" => $row["Productsupply"],
  9. "Type" => $row["Producttype"],
  10. "Tags" => $row["Tags"],
  11. "Materials" => $row["Materials"],
  12. "Date" => $row["Releasedate"],
  13. "Description" => $row["Description"],
  14. "isDigital" => $row["isDigital"],
  15. "MainPhoto" => $row["MainPhoto"],
  16. "Photo01" => $row["Productpic01"],
  17. "Photo02" => $row["Productpic02"],
  18. "Photo03" => $row["Productpic03"]
  19. ];
  20. }
  21. } else {
  22. echo "0 results found. Please check database connection.";
  23. }
  24.  
  25. $Filterarray = array('Pluimstaart'); //Might filter on more keywords in future usage.
  26. $newArr = array();
  27. foreach ($product as $key => $value) {
  28. foreach ($value as $finalVal) {
  29. if(in_array($finalVal, $Filterarray)){ // check if available in filter array
  30. $newArr[$key]["ID"] = $value["ID"];
  31. $newArr[$key]["Name"] = $value["Name"];
  32. $newArr[$key]["Price"] = $value["Price"];
  33. $newArr[$key]["Supply"] = $value["Supply"];
  34. $newArr[$key]["Type"] = $value["Type"];
  35. //$newArr[$key][] = $finalVal;
  36. }
  37. }
  38. }
  39.  
  40. Array
  41. (
  42. [1] => Array
  43. (
  44. [ID] => 1
  45. [Name] => Pluisje de Pluimstaart
  46. [Price] => 75
  47. [Supply] => 0
  48. [Type] => Pluimstaart
  49. )
  50. [5] => Array
  51. (
  52. [ID] => 69
  53. [Name] => Blizzard de Pluimstaart
  54. [Price] => 75
  55. [Supply] => 1
  56. [Type] => Pluimstaart
  57. )
  58. )
  59.  
  60. Array
  61. (
  62. [0] => Array
  63. (
  64. [ID] => 1
  65. [Name] => Pluisje de Pluimstaart
  66. [Price] => 75
  67. [Supply] => 0
  68. [Type] => Pluimstaart
  69. )
  70. [1] => Array
  71. (
  72. [ID] => 69
  73. [Name] => Blizzard de Pluimstaart
  74. [Price] => 75
  75. [Supply] => 1
  76. [Type] => Pluimstaart
  77. )
  78. )
Add Comment
Please, Sign In to add comment