Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a few options to handle the task you're trying to accomplish:</p> <ul> <li>Convert the buttons to links and use <code>GET</code> instead of <code>POST</code>. You could make the query-string something like <code>?action=delete&amp;id=$memberId</code>.</li> </ul> <p>Try:</p> <pre><code>foreach ($memberIds as $memberId) { $listOfMembers = "&lt;b&gt;Name:&lt;/b&gt; $fNames[$i] $lNames[$i] &lt;a href=\"page.php?action=delete&amp;id=$memberId\"&gt;Delete member&lt;/a&gt; &lt;a href=\"page.php?action=changeInfo&amp;id=$memberId\"&gt;Change info&lt;/a&gt;"; $i += 1; } </code></pre> <p><br /></p> <ul> <li>Make an individual form for each member and have a hidden <code>id</code> field for each one. So, instead of wrapping the full thing with <code>&lt;form&gt;&lt;/form&gt;</code>, wrap each set of buttons instead: </li> </ul> <p>Try: </p> <pre><code>foreach ($memberIds as $memberId) { $listOfMembers = "&lt;b&gt;Name:&lt;/b&gt; $fNames[$i] $lNames[$i]"; $listOfMembers .= '&lt;form method="post"&gt;'; $listOfMembers .= '&lt;input type="hidden" name="id" value="' . $memberId . '" /&gt;'; $listOfMembers .= "&lt;input type='submit' name='delete' value='Delete member' /&gt;"; $listOfMembers .= "&lt;input type='submit' name='changeInfo' value='Change info' /&gt;"; $listOfMembers .= '&lt;/form&gt;'; $i += 1; } </code></pre> <p><br /></p> <ul> <li>Use JavaScript to set a hidden-field when each individual button is clicked.</li> </ul> <p>Try:</p> <pre><code>&lt;script&gt; function submit(button) { document.getElementById('id').value = button.getAttribute('id'); document.getElementById('action').value = button.getAttribute('name'); button.form.submit(); } &lt;/script&gt; </code></pre> <p>And each button you would use:</p> <pre><code>$listOfMembers .= "&lt;input type='button' id='$memberId' name='delete' value='Delete member' onclick='submit(this);' /&gt;"; $listOfMembers .= "&lt;input type='button' id='$memberId' name='changeInfo' value='Change info' onclick='submit(this);' /&gt;"; </code></pre> <p>It's all a matter of opinion really, but I would suggest the 2nd option personally (an individual form for each group) if you have to use POST; otherwise, the 1st (using GET) would be the easiest.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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