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

Reply via email to