Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="wrap">
- <div id="primary" class="content-area">
- <main id="main" class="site-main" role="main">
- <form name="frmSearch" method="post" action="custom-search-page.php">
- <div class="search-box">
- <p><input type="text" placeholder="Batch No" name="search[batch_no]" class="demoInputBox" value="<?php echo $batch_no; ?>" />
- <br/>
- <input type="text" placeholder="RFID Chip No" name="search[rfid_chip_no]" class="demoInputBox" value="<?php echo $rfid_chip_no; ?>" />
- <input type="submit" name="go" class="btnSearch" value="Search">
- <input type="reset" class="btnSearch" value="Reset" onclick="window.location=''"></p>
- </div>
- </form>
- <h2>Search Result</h2>
- <?php
- $batch_no = "";
- $rfid_chip_no = "";
- $queryCondition = "";
- if(!empty($_POST["search"])) {
- foreach($_POST["search"] as $k=>$v){
- if(!empty($v)) {
- $queryCases = array("batch_no","rfid_chip_no");
- if(in_array($k,$queryCases)) {
- if(!empty($queryCondition)) {
- $queryCondition .= " AND ";
- } else {
- $queryCondition .= " WHERE ";
- }
- }
- switch($k) {
- case "batch_no":
- $batch_no = $v;
- $queryCondition .= "batch_no LIKE '" . $v . "%'";
- break;
- case "rfid_chip_no":
- $rfid_chip_no = $v;
- $queryCondition .= "rfid_chip_no LIKE '" . $v . "%'";
- break;
- }
- }
- }
- }
- $orderby = " ORDER BY id desc";
- $sql = "SELECT * FROM {$wpdb->fishsearch} " . $queryCondition;
- $href = 'customsearchpage.php';
- ?>
- <link href="style.css" type="text/css" rel="stylesheet" />
- <?php
- if (empty($result)) {
- echo "<p>No results matched. Please try again..</p>\n";
- } else {
- ?>
- <table cellpadding="10" cellspacing="1">
- <?php
- foreach($result as $k=>$v) {
- if(is_numeric($k)) {
- ?>
- <thead>
- <tr>
- <th><strong>Name</strong></th>
- <td><?php echo $result[$k]["farm_code"]; ?></td>
- </tr>
- <tr>
- <th><strong>Code</strong></th>
- <td><?php echo $result[$k]["batch_no"]; ?></td>
- </tr>
- <tr>
- <th><strong>Category</strong></th>
- <td><?php echo $result[$k]["rfid_chip_no"]; ?></td>
- </tr>
- </thead>
- <?php
- }
- } }?>
- </table>
- </main><!-- #main -->
- </div><!-- #primary -->
- </div><!-- .wrap -->
Add Comment
Please, Sign In to add comment