Reply to Re: how to highlight cell

Your name:

Reply:


Posted by Steve on 10/19/06 05:20

ok toffee. here's the example script...sorry for the text wrapping. hth.


<?
$currentCell = $_REQUEST['currentCell'];

// setup stubbed records
$records = array();
for ($key = 0; $key < 10; $key++)
{
for ($i = 0; $i < 10; $i++)
{
$column = chr(65 + $i);
$records[$key][$column] = 'VALUE ' . $column;
$addendums[$key][$i] = 'ROW ' . $key . ' :: CELL ' . $column;
}
}

// set addendum text
$currentRow = floor($currentCell / 10);
$currentCell = $currentCell % 10;
$addendum = $addendums[$currentRow][$currentCell];

// output html
?>
<html>
<title>Cell Highlighting</title>
<style type="text/css">
a
{
color : #000060;
text-decoration : none;
white-space : nowrap;
}
a:active
{
color : #000060;
text-decoration : none;
}
a:link
{
color : #000060;
text-decoration : none;
}
a:visited
{
color : #000060;
text-decoration : none;
}
a:hover
{
color : 000060;
text-decoration : underline;
}
table
{
border-collapse : collapse;
border-padding : 2px;
border-width : 0px;
border-spacing : 0px;
}
td
{
background-color : #FFFFFF;
color : black;
font-family : verdana, tahoma, arial, 'times new
roman', sans-serif;
font-size : 8pt;
margin : 5px;
padding-left : 5px;
padding-right : 5px;
spacing : 0px;
text-align : left;
vertical-align : middle;
width : 100px;
}
th
{
background-color : lavender;
border-bottom : solid 1px lightsteelblue;
color : black;
font-family : verdana, tahoma, arial, 'times new
roman', sans-serif;
font-size : 8pt;
font-weight : bold;
margin : 5px;
padding-left : 5px;
padding-right : 5px;
text-align : left;
vertical-align : middle;
}
</style>
<body>
<table>
<?
$header = array_keys($records[0]);
echo '<th>' . implode('</th><th>', $header) . '</th>';
$index = 0;
foreach ($records as $row => $record)
{
?>
<tr>
<?
foreach ($record as $column => $value)
{
$backgroundColor = $row == $currentRow && $index == $currentCell ?
'#CCCCCC' : 'white';
$uri = '?currentCell=' . $index;
?>
<td style="background-color:<?= $backgroundColor ?>">
<a href="<?= $uri ?>" title="Click for description"><?= $value
?></a>
</td>
<?
$index++;
}
if ($row == $currentRow)
{
echo '</tr><tr>';
if ($currentCell > 0)
{
echo '<td colspan="' . $currentCell . '">&nbsp;</td>';
}
echo '<td>' . $addendum . '</td>';
}
?>
</tr>
<?
}
?>
</body>
</html>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация