|
|
Using a query from from a MySql Database alternate the color of the table row each time through the loop.
| <?php
$qry = "Select * from table";
$result = myql_query($qry);
$rs = 0; // set count of array to be 0 for first run
for($i = 0; $i < count($rs); ) {
while ($rs = mysql_fetch_array($result)) {
//divde the count by two and see if there is a remainder(odd number) and assign a color.
$bgcolor = ($i % 2) ? 'blue' : 'black';
//print results....
print "<tr>
<td bgolor=\"$bgcolor\">First Cell</td>
<td bgolor=\"$bgcolor\">Second Cell</td>
<td bgolor=\"$bgcolor\">Third Cell</td>
</tr>"; //etc
$i++;
}
}
?> | |
I posted this on a PHP board and it was suggested i post here. Hope this helps
someone. |
|
| mySQL/PHP/search with multientry
form and table output with colored rows Categories : PHP, Beginner Guides, MySQL, HTML and PHP, Databases | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | | | Required form fields that pull from MySQL database Categories : PHP, HTML and PHP, Databases, MySQL | | | Function to do live population of HTML's <Select> tag from a Table Categories : PHP, MySQL, HTML and PHP, Databases | | | Storing / Retrieving pictures from database This can be used for banner / ads exchange. very useful for people developing big portal with ads in the site........ Categories : PHP, MySQL, Databases, HTML and PHP | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | html split bar used to split in multiple pages a database result Categories : HTML and PHP, Databases, MySQL, PHP | | | A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Paginating the mySQL data Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP | | | DDN FFA Network Script Categories : PHP, MySQL, Complete Programs, HTML and PHP, Databases | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | |
| |
| | | | | Tom Smith wrote :875
Just wot I was looking for :) Thanks very much to whoever wrote this.
(creating an insurance database)
| |
|
|