SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 339 | Next

Craig Grannell

"The Essential Guide to CSS and HTML Web Design"

After the PHP for retrieving data and the opening table markup
(including headers), you add the following:
$alternate = TRUE;
while ($row = mysql_fetch_object($sqlresult)) :
if($alternate) :
$class = ' class="alt"';
$alternate = FALSE;
else :
$class = "";
$alternate = TRUE;
endif;
echo '';
echo '' . $row->field1 . '';
echo '' . $row->field2 . '';
echo '';
endwhile;
This is then followed by the markup to close the table. Note that in this example, the alt
class value is applied to alternate table rows, so the CSS from the previous exercise should
still work fine.
Tables for layout
This section is going to be brief, because you should avoid using tables for layout, or even
components of a layout (excepting tabular data, obviously). There are exceptions??”for
instance, some web designers consider tables acceptable for laying out forms. However,
generally speaking, tables are less accessible than CSS, harder to maintain and update,
slow to render in browsers, and don??™t print particularly well. More importantly, once you
know how to create CSS-based layouts, you??™ll mostly find working with tables for layout
frustrating and clunky.
To add stripes to more tables, just assign each one a unique id value and then
add another line to the window.onload function in the JavaScript document, as
per the instructions in this exercise. For example, if you added a table with an id
value of playlist2, the line of JavaScript to add to the function would be
ZebraTable.


Pages:
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6