Hide results minus the selected SELECT

0

Good the other day a colleague from here helped me to show in a select the references that there are of a product in a select and those available and those that came from other references to hide them. (This is editing a record)

All this is working with manners.

With this I send the data to the modal

 <td class="otrotdfgaz" id="select2-3<?php echo $res['pedID']; ?>">
   <?php
     if($res['Referencia'] == null) echo "<span>Sin asignar</span>";
     else{
     ?>
     <span><?php echo $res['Referencia']; ?></span>
    <?php  } ?>
 </td>

With this I get it in the modal

 $('select#select2-3 option').each(function(index, option) { 
   var ids = option.id.split('_'); 
   var optionQuery = $(option);
      if (ids.length == 2) {
      if (ids[1] == proId) { 
       optionQuery.prop('disabled', false);
       } else { 
       optionQuery.prop('disabled', true); 
      } 
     }
   });

   if(Ref == 'Sin asignar')
     $('select#select2-3').val('0').trigger('change');
       else
     $('select#select2-3').val(Ref).trigger('change');

With this charge the bd references and also makes it show the selected one.

 <select id="select2-3" value="" class="form-control" name="select2-3">
    <option value="">Sin asignar</option>
 <?php
  $results = $mysqli->query("SELECT * FROM referencias WHERE estadoMaquina = 0 ");                                                              
  mysqli_set_charset("utf8");                                                                   
  while($res = $results->fetch_array()) {
 ?>

 <option value="<?php echo $res['referencia']; ?>" id="<?php echo $res['id'].'_'.$res['idProducto']; ?>"><?php echo $res['referencia']; ?></option> 

 <?php } ?>
 </select>

The thing is that now I made that when editing an order and adding a reference to that order I modify two tables, one the order and the other the references, where in references I change the machine state to which it corresponds.

Clear in the query to only show those that have machine = 0 status because it does not show me the selected one because it is not like 0.

I wonder if there is any way to hide all those that are in 0 but to show the selected one ???

Thanks Greetings

    
asked by Miguel 18.09.2018 в 09:02
source

0 answers