phphtml-tablewordsearch

POST the value of an array index stored in hidden fields


I am creating a wordsearch, I'm trying to post the value in another page, The problem is that I cannot display all the value of $thisChar to another page, all I get is the last letter. So the question is how can you post a variable that is something like this e.g., $rc[$r][$c]...

This is my form. I have hidden fields that named thisChar.

echo '<form method="post" action="#path" target="blank">';
echo '<table>';
    #--Display the random letters and the words

    for ($r=0;$r<=$row;$r++) {
        echo '<tr>';
        for ($c=0;$c<=$col;$c++) { 

            $thisChar=strtoupper($rc[$r][$c]); 

            echo '<input type="hidden" name="thisChar" value="'. $thisChar.'">';

               echo '<td  style="background:#fff">' . $thisChar . '</td>';

        }
               echo '</tr>';
 }

 echo '</table>';
 echo '<input type="submit" name="submit">';
 echo '</form>';

This is how I fetch the post data. All I get is Uninitialized offset error.

for ($r=0;$r<=$row;$r++) {
    for ($c=0;$c<=$col;$c++) { 
        $thisChar=$_POST['thisChar'];       
        $pdf->Cell(10,10, strtoupper($thisChar) ,1,0,'C', );    
    }       
}

I already tested other approach like foreach loop and adding square brackets on the name of hidden fields and it works, now I want to make it work using this approach. This method creates a loop that can display in a table. Any idea how can I make it works?


Solution

  • You need to post it as array, so your name attribute should look like this:

    echo '<input type="hidden" name="thisChar[]" value="'. $thisChar.'">';
    

    haven't check the rest of your code, but this will send all the values as an array