首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >按钮执行表问题中的PHP脚本

按钮执行表问题中的PHP脚本
EN

Stack Overflow用户
提问于 2013-12-31 01:50:10
回答 2查看 64关注 0票数 0

我已经设置了一个脚本,在一个表中显示我的数据库的所有成员,这些成员都有所谓的“挂起点”。在该表中有一个按钮,管理员可以单击该按钮,将表中那一行中的那些挂起的点数发送给用户,并将“挂起的点数”重置为0。我已经编写了发送这些点的脚本,但它似乎没有改变任何东西,即使它确实提供了成功的消息。如有任何帮助,我们不胜感激!

这是一张可以澄清的图片:

用于发送积分的代码(sendpoints.php):

<?  
include ("connect.php");

$result = mysqli_query($conn,"SELECT * FROM members WHERE pendingpoints > 0 ");
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);

$send = $_POST['send'];

 if ($send) {

 mysqli_query($conn,"UPDATE members SET points='$newpoints' WHERE    
     username='$username'");
 mysqli_query($conn,"UPDATE members SET pendingpoints='0' WHERE   
     username='$username'");

         $username = $row['username'];
         $pendingpoints = $row['pendingpoints'];
         $points = $row['points'];
         $newpoints = $points + $pendingpoints;

 echo "Succesfully changed points for that user";

 }

 ?>

用于显示表的代码:

<?
include ("connect.php");
$submit = $_POST['submit'];
if ($submit) {

 $result = mysqli_query($conn,"SELECT * FROM members WHERE pendingpoints > 0 ");
 $row = mysqli_fetch_array($result,         MYSQLI_ASSOC);

 while ($row = mysqli_fetch_assoc($result))
 {
 $username = $row['username'];
 $pendingpoints = $row['pendingpoints'];
 $points = $row['points'];
 $newpoints = $points + $pendingpoints;
 $ip = $row['ip'];

 echo "<table border='1'> 

 <tr>
     <td><b>Username:</b></td>   
     <td><b>Pendingpoints:</b></td>     
     <td><b>IP:</b></td>     
     <td><b>Confirm Points:</b></td>


 </tr> 
 <tr>
     <form id='1' action='sendpoints.php' method='post'>
     <td> $username </td>  
     <td> $pendingpoints </td>       
     <td> $ip </td>      
     <td><input type='submit' class='classname' name='send' value='Send'></form></td> 
 </tr>   

 <br> </table>"; 
}
}


?>
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20844736

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档