Guest User

Untitled

a guest
Sep 12th, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <div class="wrap">
  2. <div id="primary" class="content-area">
  3. <main id="main" class="site-main" role="main">
  4. <form name="frmSearch" method="post" action="custom-search-page.php">
  5. <div class="search-box">
  6. <p><input type="text" placeholder="Batch No" name="search[batch_no]" class="demoInputBox" value="<?php echo $batch_no; ?>" />
  7. <br/>
  8. <input type="text" placeholder="RFID Chip No" name="search[rfid_chip_no]" class="demoInputBox" value="<?php echo $rfid_chip_no; ?>" />
  9. <input type="submit" name="go" class="btnSearch" value="Search">
  10. <input type="reset" class="btnSearch" value="Reset" onclick="window.location=''"></p>
  11. </div>
  12. </form>
  13.  
  14. <h2>Search Result</h2>
  15.  
  16. <?php
  17. $batch_no = "";
  18. $rfid_chip_no = "";
  19.  
  20. $queryCondition = "";
  21. if(!empty($_POST["search"])) {
  22. foreach($_POST["search"] as $k=>$v){
  23. if(!empty($v)) {
  24.  
  25. $queryCases = array("batch_no","rfid_chip_no");
  26. if(in_array($k,$queryCases)) {
  27. if(!empty($queryCondition)) {
  28. $queryCondition .= " AND ";
  29. } else {
  30. $queryCondition .= " WHERE ";
  31. }
  32. }
  33. switch($k) {
  34. case "batch_no":
  35. $batch_no = $v;
  36. $queryCondition .= "batch_no LIKE '" . $v . "%'";
  37. break;
  38. case "rfid_chip_no":
  39. $rfid_chip_no = $v;
  40. $queryCondition .= "rfid_chip_no LIKE '" . $v . "%'";
  41. break;
  42. }
  43. }
  44. }
  45. }
  46. $orderby = " ORDER BY id desc";
  47. $sql = "SELECT * FROM {$wpdb->fishsearch} " . $queryCondition;
  48. $href = 'customsearchpage.php';
  49. ?>
  50. <link href="style.css" type="text/css" rel="stylesheet" />
  51. <?php
  52. if (empty($result)) {
  53. echo "<p>No results matched. Please try again..</p>\n";
  54. } else {
  55. ?>
  56.  
  57. <table cellpadding="10" cellspacing="1">
  58. <?php
  59. foreach($result as $k=>$v) {
  60. if(is_numeric($k)) {
  61. ?>
  62. <thead>
  63. <tr>
  64. <th><strong>Name</strong></th>
  65. <td><?php echo $result[$k]["farm_code"]; ?></td>
  66. </tr>
  67. <tr>
  68. <th><strong>Code</strong></th>
  69. <td><?php echo $result[$k]["batch_no"]; ?></td>
  70. </tr>
  71. <tr>
  72. <th><strong>Category</strong></th>
  73. <td><?php echo $result[$k]["rfid_chip_no"]; ?></td>
  74. </tr>
  75. </thead>
  76.  
  77.  
  78.  
  79. <?php
  80. }
  81. } }?>
  82.  
  83. </table>
  84.  
  85.  
  86.  
  87. </main><!-- #main -->
  88. </div><!-- #primary -->
  89. </div><!-- .wrap -->
Add Comment
Please, Sign In to add comment