help great great gurus of PHP programming?

<?
$c = $_POST['col'];
$r = $_POST['rw'];
?>

<?
for($cvchk = 1; $cchk<= $c; $cchk ++)
{
echo $cchk."<br>";

for($rchk = 1; $rchk<= $r; $rchk ++)
{
echo $rchk." ";
}
}

?>
i don’t know what is wrong with this one
i want the output to become this one

1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3

i really kinda new with this thanks a lot guys

guys can you help me out with this one..
or how about like this

1 2 3 4
2 4 6 8
$c = $_POST['col'];
$r = $_POST['rw'];

this two are text box and that’s where i’m gonna put the numbers.

You don’t an initial value for $cchk so nothing happens. Change $cvchk to $cchk and something will happen.

If you post col=4 and rw=3 you’ll get
1 2 3 1
1 2 3 2
1 2 3 3
1 2 3 4
1 2 3

Which isn’t what you want. So what do you want? It isn’t clear what rw and col do. Maybe something more like this?
for($cchk = 1; $cchk<= $c; $cchk ++)
{
echo $cchk."<br>";

for($rchk = 1; $rchk<= $r; $rchk ++)
{
echo 1+($rchk+$cchk-2)%$c." ";
}
echo "<br/>";
}

One Response to “help great great gurus of PHP programming?”

  • Peter K says:

    You don’t an initial value for $cchk so nothing happens. Change $cvchk to $cchk and something will happen.

    If you post col=4 and rw=3 you’ll get
    1 2 3 1
    1 2 3 2
    1 2 3 3
    1 2 3 4
    1 2 3

    Which isn’t what you want. So what do you want? It isn’t clear what rw and col do. Maybe something more like this?
    for($cchk = 1; $cchk<= $c; $cchk ++)
    {
    echo $cchk."<br>";

    for($rchk = 1; $rchk<= $r; $rchk ++)
    {
    echo 1+($rchk+$cchk-2)%$c." ";
    }
    echo "<br/>";
    }
    References :

Leave a Reply