HTML form values are not varying within the while PHP

2

Well, I made an extract that selects the data from the DB and prints it on the screen through the while, which is generating the correct values, but now I'm trying to create an edit button that opens a popup with the inputs already populated with the values, but this form is only receiving the values of the 1st loop. Anyone have any suggestions for solving the problem?

Here is the code I'm trying to fix:

while($linha=$buscarextrato->fetch(PDO::FETCH_ASSOC)){
echo '
<div class="div" style="border:0px;width:80px;">
    <div data-role="popup" id="Popup" class="ui-content" style="min-width:500px;">
            <form style="display:inline;" name="lanc" action="editalanc.php" method="POST" enctype="multipart/form-data" >
                <input type="hidden" name="numlanc" value="'.$linha[lancamento].'"/>
                <input type="date" name="data" value="'.$linha[data].'"/>
                <input type="number" name="debito" value="'.$linha[debito].'"/>
                <input type="number" name="credito" value="'.$linha[credito].'"/>
                <input type="number" name="valor" value="'.$linha[valor].'"/>
                <input type="text" name="descricao" value="'.$linha[descricao].'"/>
            </form>
    </div>
    <a href="#Popup" data-rel="popup"><i class="material-icons">mode_edit</i></a>
</div>
    ';

JS code obtained by reference:

 <script src="https://code.jquery.com/jquery-1.11.3.min.js"></script><scriptsrc="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

CSS:

<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
The generated values (line) vary correctly in each loop, the only thing that does not change is the form, it seems to me that it gets the value of 1 loop and ignores the rest.

/ p>     

asked by anonymous 07.11.2017 / 14:38

2 answers

1

<div data-role="popup" id="Popup'.linha[lancamento].'" class="ui-content" style="min-width:500px;">

I concatenated the launch line that is unique to generate a popup in each loop. I did the same for the button as the reference.

<a href="#Popup'.linha[lancamento].'" data-rel="popup"><i class="material-icons">mode_edit</i></a>
    
07.11.2017 / 15:15
0

Use fetchAll instead of fetch

The fetch will return a simple array, it is ideal when there is only one record, since fetchAll will return an array with all results.

    
07.11.2017 / 14:45