RE: [PHP] Alternet row colors
| From: | Boaz Yahav | Date: | Sat, 15 Nov 2003 16:09:18 +0000 |
| Subject: | RE: [PHP] Alternet row colors | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-169735@lists.php.net to get a copy of this message | ||
You can also check :
A PHP function To Make Alternative Colored table rows
http://www.weberdev.com/get_example.php3?count=3609
Alternating background color for HTML table rows
http://www.weberdev.com/get_example.php3?count=3482
Another way to alternate table rows
http://www.weberdev.com/get_example.php3?count=1832
How to display any array in several rows and columns of a table. Not just in one column or in
alternate rows. This example shows a nice color table generated with PHP, but can be used with any
array values(e.g. Database)
http://www.weberdev.com/get_example.php3?count=1761
HTML Table with random alternating colours, helps you see what you colour options are.
http://www.weberdev.com/get_example.php3?count=1555
Sincerely
berber
Visit http://www.weberdev.com/ & http://www.weberblog.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com
Search for PHP Code from your browser http://toolbar.weberdev.com
Share your thoughts : http://www.weberblog.com/submit.php?type=story&topic=PHP_Web_Logs
-----Original Message-----
From: PAUL FERRIE [mailto:info@innovativedesigns.org.uk]
Sent: Saturday, November 15, 2003 5:46 PM
To: php-general@lists.php.net
Subject: [PHP] Alternet row colors
Hello all
I have been working on this website http://thor.ancilenetworks.co.uk/~pferrie/vinrev/index2.htm
I did not design the site i have just been asked to tweak it
My php knowledge is limited always learning something new. Anyways I have been trying to use a code
that i got from www.hotscripts.com the scipts retutns alternet rows colors for information sent back
from the database when displayed in the broswer.
Here is the script:
//-------------------
function alternate_rows(
// color_1 and color_2 have default values, but can be over-ridden.
$data,
$color_1 = '#999999',
$color_2 = 'black'
)
{
// Declare $color as static so it retains its value when program // execution leaves the local
function's scope.
static $color;
// Set the color to that's not currently set.
if ( $color == $color_1 )
{
$color = $color_2;
}
else
{
$color = $color_1;
}
echo '<tr bgcolor="' . $color . '"><td>' . $data .
'</td></tr>'; }
I have tried a few was of implamenting this into my current php code but i have had no luck :(
Could some one help me with this please :)
If you check the website and click "top ten" http://thor.ancilenetworks.co.uk/~pferrie/vinrev/index2.htm
The code for return the top ten result is :
$result = mysql_query("SELECT * FROM albums where id <15");
$Count = @mysql_num_rows($result);
echo "<table border=1 cellpadding=3 cellspacing=0
bordercolor='#000000'>\n";
echo "<tr><td bgcolor='#666666'>ID</td><td
bgcolor='#666666'>ARTIST</td><td
bgcolor='#666666'>TITLE</td><td
bgcolor='#666666'>LABEL</td><td
bgcolor='#666666'>PRICE</td></tr>\n";
for ($count = 0; $count < $Count; $count++) {
// Extract post details from database
$myrow = mysql_fetch_array($result);
$id = $myrow ['id'];
$artist = $myrow ['artist'];
$title = $myrow ['title'];
$label = $myrow ['label'];
$price = $myrow ['price'];
printf("<tr
bgcolor='#000000'><td>$id</td><td>$artist</td><td>$title</td><td>$label</td>
<td>£$price</tr>\n");
}
echo "</table>\n";
?>
Cheers
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php