Reply to Re: how to highlight cell

Your name:

Reply:


Posted by Rik on 10/19/06 05:38

toffee wrote:
> thanks everyone for the suggestions and I didnt mean to start an
> argument :-/
>
> Steve - apologies for not making it clearer, but when a user clicks
> on a cell the page is indeed refreshed; i just wanted to be able to
> show which cell caused the refresh by highlighting it.


Well, let me say that first of all when displaying certain data above in a
table, on which the data below depends, I cannot imagine how it's not
possible to use a simple:

for(table_cells loop)}
$class = (selected) ? ' class="selected"':'';
echo "<td{$class}>".$some_value().'</td>';
}

But hey:

Requirements:
1. You buffer your table in variable $table, no direct output.
2. x- and y-coφrdinates are known.
3. No rowspan or colspan in sight.
4. Classnames are correctly quoted with "";
5. Attribut names or values never hold the invalid '>' (should he &lt; if
desired).

Use only on own tables with ensured above properties.

Example, I'm not testing this, so there are possible type-errors:
---CSS---
td.higlight{
background-color: yellow;
}
---PHP---

$table = //the table as you made it.
$x = //the x coordinate
$y = //the y coordinate
$regex = '|(<table.*?)
((<tr[^>]*>.*?</tr>.*?){'.($y-1).'}) #all previous rows
((<td[^>]*>.*?</td>.*?){'.($x-1).'}) #all previous cells
<td #target cell
([^>])*? #random attributes
(\s*class="([^"])*")? #perhaps existing classvalue
([^>])*? #random attributes
>|six';
$table = preg_replace($regex,'$1$2$4<td$6 class="highlight $8"$9>',$table);


/x is underestimated in regexes :-)

--
Grtz,

Rik Wasmus

[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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация