N
N
Newn2018-04-02 14:45:55
PHP
Newn, 2018-04-02 14:45:55

How to delete data from db using same variables?

There is a form

<form id="for" method="post" action="/account/" class="ng-pristine ng-valid"><table class="simple-little-table" cellspacing="0"><thead><tr><th>Валюта</th><th>Курс</th><th>Сумма от</th><th>Сумма до</th><th>Банк</th></tr></thead>
<tbody><tr><td><input type="hidden" name="coin" value="Litecoin">Litecoin</td><td><input type="hidden" name="cours" value="10000">10000</td><td><input type="hidden" name="s_min" value="1000">1000</td><td><input type="hidden" name="s_max" value="5000">5000</td><td><input type="hidden" name="bank" value="Сбербанк">Сбербанк</td><td><button class="edit" name="edit"></button></td><td><button class="del" name="del"></button></td></tr>
<tr><td><input type="hidden" name="coin" value="Litecoin">Litecoin</td><td><input type="hidden" name="cours" value="578978978">578978978</td><td><input type="hidden" name="s_min" value="1000">1000</td><td><input type="hidden" name="s_max" value="5000">5000</td><td><input type="hidden" name="bank" value="Альфабанк">Альфабанк</td><td><button class="edit" name="edit"></button></td><td><button class="del" name="del"></button></td></tr>
<tr><td><input type="hidden" name="coin" value="Bitcoin">Bitcoin</td><td><input type="hidden" name="cours" value="135165">135165</td><td><input type="hidden" name="s_min" value="1000">1000</td><td><input type="hidden" name="s_max" value="5000">5000</td><td><input type="hidden" name="bank" value="Сбербанк">Сбербанк</td><td><button class="edit" name="edit"></button></td><td><button class="del" name="del"></button></td></tr>
<tr><td><input type="hidden" name="coin" value="Bitcoin">Bitcoin</td><td><input type="hidden" name="cours" value="11565">11565</td><td><input type="hidden" name="s_min" value="1315">1315</td><td><input type="hidden" name="s_max" value="13516">13516</td><td><input type="hidden" name="bank" value="Сбербанк">Сбербанк</td><td><button class="edit" name="edit"></button></td><td><button class="del" name="del"></button></td></tr>
</tbody></table></form>

It outputs data from table bd in a loop. Accordingly, opposite each line, I made a button for deleting and editing. For each field added a hidden input with the value of the field in the table. How do I remove a specific line on button click. The usual method is to transfer data and write it to the variable from the last line. And how to make that a particular line is deleted or edited?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lone Ice, 2018-04-02
@daemonhk

It all depends on how you open the edit window, if it is a pop-up window, then pass the js data- parameter with the entry id, if you reload the page, then pass it through $_GET.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question