0

I have this code but when I press the submit button No data is being transferred via Get, with the exemption on the submit.

<table cellspacing="0px">
    <tr>
    <td>Name</td><td>Today - <?php echo $date;?></td>
    </tr>
    <form method="get" action="update_reg.php">
    <?php
    $result = mysqli_query($con,"SELECT * FROM TABLE WHERE GROUP = 'Penguins' ORDER BY Rank, Name ");
    while($row = mysqli_fetch_array($result))
      {
      echo "<tr>";
      echo "<td>";
      if($row['Rank'] == "a"){
        $rank = "TOP ";
      }
      if($row['Rank'] == "b"){
        $rank = "MIDDLE ";
      }
      if($row['Rank'] == "c"){
        $rank = "SECOND ";
      }
      if($row['Rank'] == "d"){
        $rank = "BOTTOM ";
      }
      if($row['Rank'] == "e"){
        $rank = "";
      }
      echo $rank . $row['Name'] . "</td>";
      $num = $num + 1;
      echo "<td><input type=\"text\" class=\"today\" id=\"" . $row['id'] . "\" data-number=\"" . $num . "\" size=\"1\" maxlength=\"1\"></td></tr>";
      }
    ?>
</table>
<input type="submit" value="submit">
</form>

For some reason this isn't working, anyone got any ideas why? Thanks in advance.

3 Answers 3

2

You need to add a value="" attribute and name="" attribute to your <input>s.

For example:

echo "<td><input type=\"text\" class=\"today\" id=\"" . $row['id'] . "\" name=\"" . $row['id'] . "\" data-number=\"" . $num . "\" value=\"" . $num . "\" size=\"1\" maxlength=\"1\"></td></tr>";

I'm not sure what you're trying to submit exactly, but place that in the value for the value attribute and make sure to give each one a name attribute and value. In my example, I used $num for the value and $row['id'] for the name.

Sign up to request clarification or add additional context in comments.

Comments

2

None of your <input> tags have name attributes. No name, no form submission.

Comments

1

GROUP is a reserved keyword. So you need to backtick it as

`GROUP`


SELECT * FROM TABLE WHERE `GROUP` = 'Penguins' ORDER BY Rank, Name 

UPDATE FROM LAST COMMENT

Input need a name which is not there and if you give same name for all of them they will not work. So give a name="something[]" and on submit get the data as array

4 Comments

Thanks, that was just an example, normally it is another word, the page is showing fine with data from the DB, but when i fill in the text boxes it produces and click submit no data is transferred.
what u are trying to submit ? which fields ?
All <input> boxes which are generated by the PHP echo.
They need a name which is not there and if you give same name for all of them they will not work. So give a name="something[]" and on submit get the data as array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.