-
I need to start from the option selected in
<select>
, I check with the bank what's related to this option. I made it from as follows, but in the$p_id = $result['p_id'];
part, there is null return, I already used this array association code other times and it worked. -
I also need this to be hidden until the moment of choice of
<option>
, after displaying what I did, with the records. I do not know the which is wrong, but I accept suggestions for solution and thank you right away.<div class="form-group"> <div class="col-sm-3"> <label for="exampleInputEmail1">Cliente</label> <select class="form-control m-b-10" required="required" name="e_id" charset="utf-8"> <option>Selecione o cliente</option> <?php $select = "SELECT e_id, nome FROM pessoas"; $result = mysqli_query($conexao, $select); while($exibe = mysqli_fetch_assoc($result)){ $e_id = $exibe['e_id']; echo '<option charset="utf-8" value = '. $e_id . '>' . $exibe['nome'] . '</option>'; } mysqli_free_result($result); ?> </select> </div> </div> </form> <!--<button name="salvar" class="btn btn-success" onclick="showElement();">Pesquisar</button>--> <div id="dados" class="form-group" onload="hideElement();"> <?php if ($e_id <> '') { $select = "SELECT p_id FROM itens WHERE e_id = '$e_id'"; $result = mysqli_fetch_assoc(mysqli_query($conexao, $select)); $p_id = $result['p_id']; $select2 = "SELECT descricao where p_id = '$p_id'"; $resulta = mysqli_query($conexao, $select2); if (mysqli_num_rows($resulta) > 0){ echo '<table class="table table-hover" > <thead> <tr> <th>Descrição</th> </tr> </thead> <tbody> <tr>'; while($exibe = mysqli_fetch_assoc($resulta)){ $p_id = $exibe['p_id']; echo '<tr>'; echo '<td value = "">' . $exibe['descricao'] . '</td>'; } }else{ echo '<label for="exampleInputPassword1">Não há registros</label>'; } }else{ echo '<label for="exampleInputPassword1">Não há registros</label>'; } mysqli_free_result($result); mysqli_free_result($resulta); ?> </tr> </tbody> </table>