Note that there are some explanatory texts on larger screens.

plurals
  1. POButton to perform a PHP script in a table issue
    text
    copied!<p>I have set a script to show all members of my database in a table that have so called 'Pending Points' . In that table there's a button that an admin can click to send those pending points to 'Points' to the user in that row of the table and resetting the 'Pending Points' to 0. I have made the script to send these points but it doesn't seem to change anything even though it does give the success message. Any help is appreciated !</p> <p><strong>Here's an image that will clarify:</strong> <img src="https://i.stack.imgur.com/ypRkU.jpg" alt="enter image description here"></p> <p><strong>Code to send the points (sendpoints.php):</strong></p> <pre><code>&lt;? include ("connect.php"); $result = mysqli_query($conn,"SELECT * FROM members WHERE pendingpoints &gt; 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"; } ?&gt; </code></pre> <p><strong>Code to show the table:</strong></p> <pre><code>&lt;? include ("connect.php"); $submit = $_POST['submit']; if ($submit) { $result = mysqli_query($conn,"SELECT * FROM members WHERE pendingpoints &gt; 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 "&lt;table border='1'&gt; &lt;tr&gt; &lt;td&gt;&lt;b&gt;Username:&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Pendingpoints:&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;IP:&lt;/b&gt;&lt;/td&gt; &lt;td&gt;&lt;b&gt;Confirm Points:&lt;/b&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;form id='1' action='sendpoints.php' method='post'&gt; &lt;td&gt; $username &lt;/td&gt; &lt;td&gt; $pendingpoints &lt;/td&gt; &lt;td&gt; $ip &lt;/td&gt; &lt;td&gt;&lt;input type='submit' class='classname' name='send' value='Send'&gt;&lt;/form&gt;&lt;/td&gt; &lt;/tr&gt; &lt;br&gt; &lt;/table&gt;"; } } ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload