Undefined Index PHP-Mysql

0

I have the following error, it appears to me that some indexes are not defined income and expiration both are as date type 'date' in in form probe the query in Sqlyog and it does not show any error then I do not know what it could be in the fields of the form have the names of entry and expiration

Well I have 2 tables one called medication_detail and another called medication

medicine_detail id_medicamento_detalle-primary key medication_id fk quantity lot admission date date_date

medication medication_id medication

<?php $resulttt = mysqli_query($connect, "SELECT p.id_medicamento_detalle,m.medicamento,p.cantidad,p.lote,p.fecha_ingreso,p.fecha_vencimiento
FROM medicamento_detalle AS p
INNER JOIN medicamento AS m
ON p.id_medicamento=m.id_medicamento
WHERE id_medicamento_detalle='$id_medicamento_detalle'");
  $r = mysqli_fetch_array($resulttt);
  $id_medicamento = $r['medicamento'];
  $cantidad = $r['cantidad'];
  $lote = $r['lote'];
  $fecha_ingreso = $r['ingreso'];
  $fecha_vencimiento = $r['vencimiento'];
  
   ?>

<form method="POST" action="update_control.php">
    
      <div class="form-group">
                    <label for="medicamento">Medicamento</label>
                    <select style="width:450px" id="medicamento" name="medicamento">
                      <option>Seleccione</option>
                      <?php 
                      $query = "SELECT * FROM medicamento ORDER BY medicamento";
                      $medi=$connect->query($query); 
                      while($row = mysqli_fetch_assoc($medi)) { ?>
                      <option value="<?php echo $row['id_medicamento']; ?>"><?php echo $row['medicamento']; ?></option>
                       <?php } ?>
                    </select>
                  </div>

        <div class="form-group">
          <input type="text" name="cantidad" class="form-control" placeholder="Cantidad" required="" value="<?php echo $cantidad; ?>">
        </div><!-- form-group -->

        <div class="form-group">
          <input type="text" name="lote" class="form-control" placeholder="Lote" required="" 
          value="<?php echo $lote; ?>">
        </div><!-- form-group -->

        <div class="form-group">
          <input type="date" name="ingreso" class="form-control" required="" 
          value="<?php echo $fecha_ingreso; ?>">
        </div>

      <!-- form-group -->
      <div class="form-group">
          <input type="date" name="vencimiento" class="form-control"  required="" 
          value="<?php echo $fecha_vencimiento; ?>">
        </div>
    <!--form-group -->
    
  <!-- form-group -->
 
        <!-- form-group -->
        <input type="hidden" name="id_medicamento_detalle" value="<?php echo $id_medicamento_detalle; ?>">
        <div class="form-group">
          <input type="submit" name="update" class="btn btn-info" value="Editar Control">
        </div><!-- form-group -->
       </form><!-- form -->
<?php endif; ?>
    
asked by Shein 30.06.2018 в 08:40
source

1 answer

0

The names of the fields in the query are not the same as the index you use to call them in the array.

$fecha_ingreso = $r['fecha_ingreso']; //$fecha_ingreso = $r['ingreso'];
$fecha_vencimiento = $r['fecha_vencimiento']; //$fecha_vencimiento = $r['vencimiento'];
    
answered by 30.06.2018 / 08:55
source