0
I am having a problem and I could not find a solution, it can be simple, but I am not filling the error. If you can help me, thank you! next, I made a script where I can get the PRICE of the TABLE "PRODUCTS" and add to an input, the PRICE of the product is added normally, but when clicking on the Ubmit is shown the error Undefined index price. I’ll show you the code right below.
This is my HTML, where I select the product and the corresponding value.
<select name="nome" class="form-control" id="produto" >
<option>Selecione o produto do pedido </option>
<?php
include_once 'banco.php';
$pdo = Banco::conectar();
$sql = 'SELECT * FROM products ORDER BY id DESC';
foreach($pdo->query($sql)as $row){
echo '<tr>';
echo '<option class="valores" data-valor="'.$row['preco'].'">'.$row['nome'].'</option>';
echo '</tr>';
}
echo '</select><br>';
?>
<div class="form-group">
<label class="preco">Preço do produto</label><br>
<div class="col-sm-10">
<input type="text" id="valor" name="valor" disabled="disabled" class="form-control select2" style="width: 30%;" placeholder=" 00">
Here is the mistake!!
Notice: Undefined index: valor in /opt/lampp/htdocs/orquidariaVersion1.0.1/pages/adm/register_pedidos.php on line 112
Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'valor' cannot be null
you have null records in the Value column, take a first look at your PRODUCTS table.
– aa_sp
Share all your code so the community can help you.
– LSA