Note that there are some explanatory texts on larger screens.

plurals
  1. POGrouping values of table elements by id
    text
    copied!<p>I'm making a webpage where one can modify points of players.</p> <p>Table structure is like this Contestant (text), Points(input text field with default value current player's points), submit</p> <p>now, in mysql db every contestant has an id, what i want to do is when someone changes a player's points and clicks submit to be able to relate by id which player got submited. This is organized in an html table and i have no clue how to group the data. Anyone can help?</p> <p>Okay not sure if this is correct, cause i wrote it really fast, but I hope you'll get the idea.</p> <pre><code>$query = "SELECT `con`.`id`, `av`.`name` as `contestant`, `con`.`points` as `points` FROM `contestants` as `con` JOIN `mydb`.`avatars` as `av` WHERE `con`.`boardId`=$id"; $result = mysql_query($query) or die("ERROR:QUERY_FAILED " . mysql_error()); echo "&lt;h4&gt;Boards List&lt;/h4&gt;&lt;br/&gt;"; $numFields = mysql_num_fields($result); echo "&lt;table&gt;"; echo "&lt;tr&gt;"; for($i = 0; $i &lt; $numFields; $i++) { if(mysql_field_name($result,$i) != 'id') { echo "&lt;th&gt;"; echo mysql_field_name($result,$i); echo "&lt;/th&gt;"; } } echo "&lt;/tr&gt;"; while($row = mysql_fetch_row($result)) { echo "&lt;tr&gt;"; for($i = 0; $i &lt; $numFields; $i++) { if(mysql_field_name($result, $i) == 'points') { echo "&lt;td&gt;&lt;input name='points' type='number' min='0' max='45' value='$row[$i]'&gt;&lt;/td&gt;"; } else { echo "&lt;td&gt;$row[$i]&lt;/td&gt;"; } } echo "&lt;td&gt; &lt;input type='button' value='Save' onclick='SavePlayersData(this)'&gt; &lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; </code></pre> <p>What I need is a way to tell to javascript which input field it should process as the players points being saved. hope it makes sense. (btw, there will be more fields than just points. This is just an example.</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