-1

I'm trying to create a multiplication table in PHP which goes from table 1 to 10.

But it's telling me there's an unexpected for loop on line 58. Is there anyone that could tell me how i could fix this? I'm trying to learn more about PHP. This is for a school project.

        $math = 1;
        $math_2 = 1;

        $int = 0;
        $int_2 = 0;
        $table = 1;



        for($go = 5; $int < $go; $int++) {

            $table_1 = '<table style="float: left; width:15%">
                            <tr>
                                 <th>Tafel van '. $table++ .'</th>
                            </tr>            
                            <tr>

                               <td> '. $math .' * '. $math_2 .' = '


                                    for ($start = 5; $int_2 < $start; $int_2++){

                                        echo ''. ($math * $math_2) .'';

                                    }'


                             </td>                          

                            </tr>
                     </table>';
            echo $table_1;
            $math++;

        }
  • And which of the 35 lines you have currently shown us is supposed to be line number 58 ...? – misorude Oct 30 '18 at 10:31
  • FATAL ERROR syntax error, unexpected 'for' (T_FOR) on line number 23 – Daan Oct 30 '18 at 10:32
  • Sorry it's line 23 for you guys haha, I didn't think of adding the HTML Code as wel.. – Bas Kruithof Oct 30 '18 at 10:33
  • 2
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Nick Oct 30 '18 at 10:37

1 Answers1

2

You're missing a closing semicolon on the line before the for loop:

                       <td> '. $math .' * '. $math_2 .' = ';

For more detail on how to fix syntax errors, you can follow this link: PHP parse/syntax errors; and how to solve them?

I don't see how that code is going to do what you want though. There's some work for you to do concerning the nesting of your for loops and your <tr><td> tags.

Ben Hillier
  • 2,126
  • 1
  • 10
  • 15