Skip to content

Instantly share code, notes, and snippets.

@iBasit
Created June 15, 2017 14:02
Show Gist options
  • Save iBasit/923d20e12361e3ddae76ca9b65a53289 to your computer and use it in GitHub Desktop.
Save iBasit/923d20e12361e3ddae76ca9b65a53289 to your computer and use it in GitHub Desktop.
<style>
td {
border: 1px solid black;
margin: 2px;
padding: 2px;
}
.marked {
background-color: red;
}
</style>
<table>
<?php
$rows = 9;
$columns = 9;
for ($i=1; $i<=$rows; $i++)
{
?>
<tr>
<?php
for ($c=1; $c<=$columns; $c++)
{
$marked = '';
if (($i == 1 || $i == 9) && ($c == 1 || $c == 9))
$marked = 'marked';
elseif (($i == 2 || $i == 8) && ($c == 2 || $c == 8))
$marked = 'marked';
elseif (($i == 3 || $i == 7) && ($c == 3 || $c == 7))
$marked = 'marked';
elseif (($i == 4 || $i == 6) && ($c == 4 || $c == 6))
$marked = 'marked';
elseif ($i == 5 && $c == 5)
$marked = 'marked';
?>
<td class="<?php echo $marked; ?>"></td>
<?php
}
?>
</tr>
<?php
}
?>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment