Field help to autocomplete with PHP and Mysql

0

Hello good day I explain myself I have a program called add_sale.php which is used to capture data in some text fields and this information will go to a database my problem is that I would like the text field with the name noparte had the function of bringing said part number from a different database with the function of autocompletado if someone could help me I would appreciate much     

<?php
if(isset($_POST['add_product'])){
$req_fields = array('noparte','descripcion','categoria',
);

validate_fields($req_fields);
if(empty($errors)){
 $p_part = remove_junk($db->escape($_POST['noparte']));
 $p_desc   = remove_junk($db->escape($_POST['descripcion']));
 $p_cat   = remove_junk($db->escape($_POST['categoria']));

 $query  = "INSERT INTO entradas(";
 $query .=" noparte,categoria,descripcion;

 $query .=") VALUES (";

 $query .=" '{$p_part}', '{$p_cat}'
 '{$p_desc}'";
 $query .=")";
 $query .=")";

 $query .=" ON DUPLICATE KEY UPDATE descripcion='{$p_desc}'";
 if($db->query($query)){
   $session->msg('s',"Producto agregado exitosamente. ");
   redirect('add_sale.php', false);
  } 

  else { 
   $session->msg('d',' Lo siento, registro falló.');
   redirect('sales.php', false);
 }

 }

 else{
 $session->msg("d", $errors);
 redirect('add_sale.php',false);
 }

 }

?>

 <div class="panel panel-default">
    <div class="panel-heading">
      <strong>
        <span class="glyphicon glyphicon-th"></span>
        <span>Lista Materiales</span>
     </strong>
    </div>
    <div class="panel-body">
     <div class="col-md-12">
      <form method="post" action="add_sale.php" class="clearfix">
        <!--Numero de Parte-->


        <div class="form-group">
          <div class="row">
            <p></p>

          <div class="col-md-6">
            <div class="input-group">
              <span class="input-group-addon">
               <i class="glyphicon glyphicon-th-large"></i>
              </span>
              <input type="text" class="form-control" name="noparte" 
             placeholder="Numero De Parte"id=”noparte”>
             </div>
            </div>

            <div class="form-group">
            <div class="input-group">
              <span class="input-group-addon">
               <i class="glyphicon glyphicon-th-large"></i>
              </span>
              <input type="text" class="form-control" name="descripcion" 
             placeholder="Descripción">
           </div>
          </div>

          <div class="form-group">
            <div class="row">


              <div class="col-md-4">
                <p></p>
                <select class="form-control" name="categoria">
                  <option value="">Selecciona una categoría</option>
                <?php  foreach ($all_categories as $cat): ?>
                  <option value="<?php echo (int)$cat['id'] ?>">
                    <?php echo $cat['name'] ?></option>
                <?php endforeach; ?>
                </select>
              </div>
              </div>
            </div>

            <button type="submit" name="add_product" class="btn btn- 
            danger">Agregar Material</button>
           </form>
           </div>
           </div>
           </div>
           </div>
    
asked by Guillermo Mireles 14.06.2018 в 18:53
source

0 answers