1

A mysql query is grabbing data from my database and posts it into input fields in a table via while-loop. This works fine, all 252 expected table rows are shown. Pushing the submit button on the respective PHP page shall send the data to a calculation script and (re-) write data into the db.

Problem: Only 200 rows are coming through to the processing page. I.e. 52 lines do not come through. I have set up a quick script to check the output and this also shows that only 200 rows come through.

What I found out already: As soon as I reduce the table row by row the number of data put through is increasing. With only 3 rows (tipp_id, tipp_heim, tipp_gast) all 252 rows come through.

Is there a limit of throughput I'm not aware of? Or any ideas how to solve that problem?

Query & table (table includes 252 rows):

$records = mysqli_query($conn, "
    SELECT
        sp.spiel_id,
        sp.tore_heimteam,
        sp.tore_gastteam,
        t.match_id,
        t.tipp_heim,
        t.tipp_gast,
        t.tipp_id
    FROM 
        spielplan sp
    LEFT JOIN tipps t
        ON sp.spiel_id = t.match_id
");
while($fields = mysqli_fetch_assoc($records)) {
?>
    <tr>
        <td><input type="text" name="tipp_ids[]" value="<?php echo fields["tipp_id"] ?>"></td>
        <td><input type="text" name="goals_hometeams[]" value="<?php echo $fields["tore_heimteam"] ?>"></td>
        <td><input type="text" name="goals_guestteams[]" value="<?php echo $fields["tore_gastteam"] ?>"></td>
        <td><input type="text" name="tipp_guestteams[]" value="<?php echo $fields["tipp_gast"] ?>"></td>
        <td><input type="text" name="tipp_hometeams[]" value="<?php echo $fields["tipp_heim"] ?>"></td>
    </tr>

Script to check POST output (output = 200 rows):

$goalsHome = $_POST['goals_hometeams'];
$goalsGuest = $_POST['goals_guestteams'];
$tippHomes = $_POST['tipp_hometeams'];
$tippGuests = $_POST['tipp_guestteams'];
$tipp_id = $_POST['tipp_ids'];

$i=0;
foreach($goalsHome as $key => $ghome) {
    $i++;
    echo $ghome.";";
    echo $goalsGuest[$key].";";
    echo $tippHomes[$key].";";
    echo $tippGuests[$key].";";
    echo $tipp_id[$key].";";
    echo "<br>";
}
echo $i;
1
  • why the form in table ??? Commented Jan 9, 2017 at 13:55

2 Answers 2

4

I believe you might be hitting your max_input_vars limit. Default is 1000.

You can solve this by editing your php.ini. (see: This post on SO)

Although I'd suggest changing the interface.

A little elaboration in the interface thing;

If you're trying to have your visitors fill out 1000+ input fields, go with the increased max_input_vars option. Period.

BUT, if the input fields are actually just a frontend mechanic, you're using them wrong (in my opinion). Input fields are what they are, INPUT fields. If you don't require input from your end-user, don't use an input field. You can use any HTML element at your disposal to show data.

If you only need one or two values from the user. Only ask for those one or two values. Maybe create a little javascript popup requesting the input you need. From there you can recalculate the data and post it back into your database with an xhttp request.

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

8 Comments

Thank you @fyntasia! I need to contact my hoster as I am not able to edit php.ini. Will follow up as soon as I get an answer.
Other question: How would you change that interface? Background: I need the values from the table to do some maths to them UPON request (i.e. clicking a button) and then update the respective values within the db. Please note: I'm an absolute PHP beginner, so no rocket science is expected.
I've edited my comment to include my vision on the input fields. I'm not familiar with your project, so I don't know what you're trying to do. I hope things are clarified for you now.
Thanks for the update. Do I understand this correctly: "1000" in max_input_vars = 1000 equals 1000 variables that are sent via POST when clicking the submit button (e.g. $_POST['goals_hometeam']?
Yes, max_input_vars = 1000 means you can only have 1000 $_POST variables.
|
2

Look at your php.ini parameter max_input_vars = 2500 the default is 2500, but yours maybe set differently. I would guess that you have exceeded that with this form

Try increasing it to a value that matches a count of all your forms inputs

max_input_vars = 3500

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.