Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

date of the year

days of the week
w
can be 0-6

and weeks of the year
W
0-53

I have checkboxes with 7 columns and 53 rows

and I want these checkboxes to correspond to an actual date of the year
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Not sure whether weeks of the year are numbered from zero.  It should be easy enough to test.

http://www.laprbass.com/RAY_temp_rgb192b.php

<?php // RAY_temp_rgb192b.php
error_reporting(E_ALL);


// SHOW THE LOCATION OF THE SELECTIONS IN THE MATRIX
if (!empty($_POST))
{
    foreach ($_POST as $key => $val)
    {
        $arr = explode('_', $key);
        $row = $arr[0];
        $col = $arr[1];
        echo "<br/>YOU CHOSE ROW $row AND COLUMN $col" . PHP_EOL;
    }
}

// GENERATE THE MATRIX
$cols = range(0,6);
$rows = range(1,53);

$out = '<table>' . PHP_EOL;
foreach ($rows as $row)
{
    $out .= '<tr>' . PHP_EOL;
    foreach ($cols as $col)
    {
        $r_c = $row . '_' . $col;
        $out .= "<td><input type='checkbox' name='$r_c' /></td>" . PHP_EOL;
    }
    $out .= '</tr>' . PHP_EOL;
}
$out .= '</table>' . PHP_EOL;

$html = <<<ENDHTML
<form method="post">
Choose a Checkbox or Several <input type="submit" />
$out
</form>
ENDHTML;

echo $html;

Open in new window

HTH, ~Ray
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks