Advertisement
schmutly

search html table from $wpdb

Mar 1st, 2019
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.98 KB | None | 0 0
  1. <!--</pre> -->
  2.  
  3.  
  4. <form>
  5.     <form method="post" action="" >
  6.     <input type="text" placeholder="Search Transactions.." name="search">
  7.     <input type="submit" class="button-primary" value="Search" name="submit">
  8.     <input type="reset" class="button-primary" value="Reset Form">
  9. </form>
  10.  
  11.  
  12. <?php
  13.  
  14. if(isset($_POST['submit']) && !empty($_POST['submit'])) {
  15.   // there is something in the field, do stuff
  16.   $search = $_POST["search"];
  17.   return_esb_searches ();
  18.   echo "searching";
  19. } else {
  20.   // trigger normal results
  21.   all_esb_results ();
  22.  echo "showing normal results display without search";
  23. }
  24.  
  25. ?>
  26.  
  27. <?php function all_esb_results ()
  28. { ?>
  29.  
  30. <div style='width:1480px; position:relative; padding:15px; background-color:#DDDDDD;'>
  31.  
  32.  
  33. <table border="1">
  34.  <tr>
  35.   <th>First Name</th>
  36.   <th>Last Name</th>
  37.   <th>Buyer's Email Address</th>
  38.   <th>Software Title</th>
  39.   <th>IP Address 01</th>
  40.   <th>IP Address 02</th>
  41.   <th>Payment Status</th>
  42.  </tr>
  43.  <?php
  44.         global $wpdb,$search;
  45.     $ipn_tables = $wpdb->prefix ."ipn_data_tbl";
  46.            //  $result = $wpdb->get_results ( "SELECT * FROM $ipn_tables" );
  47.              $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ipn_tables}"));
  48.         foreach ( $result as $print )
  49.         {
  50.          ?>
  51.           <tr>     
  52.             <td><?php echo $print->first_name;?></td>
  53.             <td><?php echo $print->last_name;?></td>
  54.             <td><?php echo $print->payer_email;?></td>
  55.             <td><?php echo $print->item_name;?></td>
  56.             <td><?php echo $print->ip_address_01;?></td>
  57.             <td><?php echo $print->ip_address_02;?></td>
  58.             <td><?php echo $print->payment_status;?></td>
  59.           </tr>
  60.  <?php } ?>
  61. </table>
  62. </div>
  63.  
  64.  <?php } ?>
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. <?php function return_esb_searches ()
  75. { ?>
  76.  
  77. <div style='width:1480px; position:relative; padding:15px; background-color:#DDDDDD;'>
  78.  
  79.  
  80. <table border="1">
  81.  <tr>
  82.   <th>First Name</th>
  83.   <th>Last Name</th>
  84.   <th>Buyer's Email Address</th>
  85.   <th>Software Title</th>
  86.   <th>IP Address 01</th>
  87.   <th>IP Address 02</th>
  88.   <th>Payment Status</th>
  89.  </tr>
  90.  <?php
  91.         global $wpdb,$search;
  92.     $ipn_tables = $wpdb->prefix ."ipn_data_tbl";
  93.     $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$ipn_tables} WHERE item_name like $search OR first_name like $search OR last_name like $search OR payer_email like $search" ));
  94.                                          //HERE item_name = %s AND payer_email = %s", $product, $serial));
  95.         foreach ( $result as $print )
  96.         {
  97.          ?>
  98.           <tr>     
  99.             <td><?php echo $print->first_name;?></td>
  100.             <td><?php echo $print->last_name;?></td>
  101.             <td><?php echo $print->payer_email;?></td>
  102.             <td><?php echo $print->item_name;?></td>
  103.             <td><?php echo $print->ip_address_01;?></td>
  104.             <td><?php echo $print->ip_address_02;?></td>
  105.             <td><?php echo $print->payment_status;?></td>
  106.         </tr>
  107.         <?php } ?>
  108.        </table>
  109.        </div>
  110.        
  111.  <?php } ?>
  112.  
  113.  
  114.  
  115.  
  116. </body>
  117. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement