Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing input checkboxes with a database
    text
    copied!<p>So I'm trying to help a friend out by writing his guild an attendance tracker for raiding and whatnot. Right now my concept is to do a select * from the user column, and make a checkbox for each user, assuming that person showed up to raid, it would pass a "1" through the form, and their raid attendance would be incremented by 1. On the users page the overall attendance would be calculated as (raidAtt / raidsTotal)*100 (since joining). </p> <p>My issue right now is that I don't really know how to get all this information passed using a single loop...</p> <p>Right now my code is something like this:</p> <pre><code> &lt;form action="raidattend.php" method="post"&gt; &lt;?php mysql_connect("$database",$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM attend WHERE UserName = $v_member ORDER BY date desc"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Member&lt;/th&gt; &lt;th&gt;Attended?&lt;/th&gt; &lt;/tr&gt; &lt;?php $i=0; while ($i &lt; $num) { $f1=mysql_result($result,$i,"UserName"); } &lt;tr&gt; &lt;td&gt;&lt;?php echo $f1; ?&gt;&lt;/td&gt;&lt;td input type="checkbox" checked value="1"&gt; </code></pre> <p>And that's where I ran into issues. I'm not sure how to pass each user and the result of the checkbox back to the database. Once I understand how to do that it's just as simple as incrementing, but I'm pretty lost.</p> <p>Thanks for any help!</p> <p>Edit: To clarify, what I'm unsure of is how to break it up so each member gets updated, I understand that I need to use a submit and all that.</p> <p>Edit 2: Stray }</p>
 

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