On Sat, Nov 15, 2003 at 06:09:18PM +0200, Boaz Yahav wrote:
>
> 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'];
>
replace
> printf("<tr
> bgcolor='#000000'><td>$id</td><td>$artist</td><td>$title</td><td>$label</td>
> <td>?$price</tr>\n");
with
echo '<tr bgcolor="'.($count % 2) ? '#fefefe' :
'#efefef'.'"><td>'.$id.'</td><td>'.$artist.'</td><td>'.$title.'</td><td>'.$label.'</td><td>'.$price."</td></tr>\n";
> }
> echo "</table>\n";
>
> ?>
>
-- zhuravlev alexander
u l s t u n o c
([EMAIL PROTECTED])
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php