2017-12-29 17:50
浏览 91

单击按钮后,在数据库中将值从0更改为1 [关闭]

I have a table:

enter image description here

I want to change "pending" to "payed" when i will click on button "Do" In the database if value of column "status" is 0 , then write pending, and if value is 1 - payed.

Code of table:

$pass="***"; //установленный вами пароль

$result=mysql_query("SELECT id,payeer,summa,dates_add, status FROM pays_tnmleafeuj  ORDER BY id DESC"); 

//$result - ассоциированный массив, т.е. таблички, у которой есть названия столбцов 

echo "<table border=1 width=700px>";
echo "<tr><th>ID</th><th>Кошелёк</th><th>Сумма</th><th>Дата</th><th>Статус</th><th>-</th></tr>";
while ($row=mysql_fetch_array($result )){
if($status == 0){
$status = 'pending';
} elseif($status == 1){
$status = 'payed';

echo "<tr><td class=id>$id</td><td>$payeer</td><td>$summa</td><td>".date('Y-m-d H:i', $row[dates_add])."</td><td>$status</td><td><input type=button value=Do SQL></td></tr>";
echo "</table>";
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douzuo0711 2017-12-29 18:09

    Checkout this answer

    Clicking a button is client side whereas updating database is Server side. So use an ajax call as described in above answer to call some php function which will then update the database.

    打赏 评论
  • dopt85756 2017-12-29 18:04

    Question is a bit vague but...

    Create a listener for your "Do" buttons. Perhaps assign id's to the buttons that match the ID of the database record. Have a section of php that makes an sql update call on the proper table. When the button is clicked, update that records status.

    It would be more help if you were to have a more specific question.

    打赏 评论

相关推荐 更多相似问题