PHP Loop

Report
Question

Please briefly explain why you feel this question should be reported .

Report
Cancel

Why output cannot come out?

Do you know where is it wrong?
<!DOCTYPE html>

<html>
<body>
<?php
echo “<table border =\”A\” style=’border-collapse: collapse’>”;
for ($row=\”A\”; $row <= \”A\”; $row++) {
echo “<tr> \n”;
for ($col=\”A\”; $col <= \”A\” $col++) {
$p = $col * $row;
echo “<td>$p</td> \n”;
}
echo “</tr>”;
}
echo “</table>”;
?>

</body>
</html>

in progress 0
PHP 3 months 2 Answer 2791 views 0

About Mira

Answers ( 2 )

  1. ritwik

    Please briefly explain why you feel this answer should be reported .

    Report
    Cancel

    This is the code which works (since the code you posted does not come with any context, logic is not clear though) :

    <!DOCTYPE html>
    <html>
    <body>
    <?php
    echo "<table border='A' style='border-collapse: collapse'>";
    for ($row="A"; $row <= "A"; $row++) {
    echo "<tr>";
    for ($col="A"; $col <= "A"; $col++) {
    $p = $col * $row;
    echo "<td>".$p."</td>";
    }
    echo "</tr>";
    }
    echo "</table>";
    ?>
    </body>
    </html>
    
  2. Please briefly explain why you feel this answer should be reported .

    Report
    Cancel

    It is not clear what do you mean by \”A\”. Assuming that you tried to write “A” which is a string. Instead you should write a numeric character.

    The loop statement for starts looping from a number and ends comparing another number incrementing a definite value.

    for ($i=1; $i < 7; $i++)
    

    means that the loop starts from 1 and ends at 6 with an increment of 1. So the loop will occur 6 time.

Leave an answer

Browse

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>