|
-
May 22nd, 2006, 06:49 AM
#1
Thread Starter
Frenzied Member
How to use diffrent color for each record output
I am using this code to output the search result for song title and currently it uses same color for all maches.What i want to use this color #FFB951 and #C0C0C0
for background of each row but not same color for consucative rows . In another word if there are 4 records i want first one to be #C0C0C0 and second #FFB951 and 3th #C0C0C0 and 4th #FFB951 .Could any one tell me how this can be done.
PHP Code:
$numbers=0;
while($row = mysql_fetch_assoc($result))
{
$numbers++; // counting number of records
?>
<?
switch ($m):
case "title": ?>
<tr>
<td bgcolor="#C0C0C0"><? echo $numbers; ?> </td>
<td bgcolor="#C0C0C0"><a
href="javascript:newWindow('./playlistfromdbtotextfile.php?songid=<?=strval( $row['id'] );?>')"><img
src="./images/Speaker.gif" alt="Listen to this Song"
border="0" width="16" height="16"
longdesc="Listen to this Song"></a> <b><?=strval( $row['songname'] );?></b> </td>
[b]<td bgcolor="#C0C0C0">[/b]<a
href=" ./albumsongs.php?albumname=<?=strval( $row['album'] );?>&artistname=<?=strval( $row['artist'] );?>"><?=strval( $row['album'] );?></a>
</td>
<td bgcolor="#C0C0C0"><a
href="albums.php?albumname=<?=strval( $row['artist'] );?>"><?=strval( $row['artist'] );?></a> </td>
td bgcolor="#C0C0C0">66 </td>
</tr>
-
May 22nd, 2006, 08:34 AM
#2
<?="Moderator"?>
Re: How to use diffrent color for each record output
try this
PHP Code:
if(($numbers%2) == 1)
{
//colour 1
}
else
{
//colour 2
}
-
May 22nd, 2006, 08:36 AM
#3
Thread Starter
Frenzied Member
Re: How to use diffrent color for each record output
 Originally Posted by john tindell
try this
PHP Code:
if(($numbers%2) == 1)
{
//colour 1
}
else
{
//colour 2
}
but what to do with <td bgcolor="#C0C0C0"> parts ? i have blocks of code with <td bgcolor="#C0C0C0"> on it ! where to place your code ?
PHP Code:
while($row = mysql_fetch_assoc($result))
{
$numbers++; // counting number of records
?>
<?
switch ($m):
case "title": ?>
<tr>
<td bgcolor="#C0C0C0"><? echo $numbers; ?> </td>
<td bgcolor="#C0C0C0"><a
href="javascript:newWindow('./playlistfromdbtotextfile.php?songid=<?=strval( $row['id'] );?>')"><img
src="./images/Speaker.gif" alt="Listen to this Song"
border="0" width="16" height="16"
longdesc="Listen to this Song"></a> <b><?=strval( $row['songname'] );?></b> </td>
<td bgcolor="#C0C0C0"><a
href=" ./albumsongs.php?albumname=<?=strval( $row['album'] );?>&artistname=<?=strval( $row['artist'] );?>"><?=strval( $row['album'] );?></a>
</td>
<td bgcolor="#C0C0C0"><a
href="albums.php?albumname=<?=strval( $row['artist'] );?>"><?=strval( $row['artist'] );?></a> </td>
<td bgcolor="#C0C0C0">66 </td>
</tr>
<? break;
case "artist": ?>
<tr>
<td width="5%" bgcolor="#C0C0C0"><? echo $numbers; ?> </td>
<td width="35%" bgcolor="#C0C0C0"><a
href="albums.php?albumname=<?=strval( $row['artist'] );?>"><b><?=strval( $row['artist'] );?></b>
</a> </td>
<td width="10%" bgcolor="#C0C0C0">467 </td>
</tr>
<? break;
case "album": ?>
<tr>
<td bgcolor="#C0C0C0"><? echo $numbers; ?> </td>
<td bgcolor="#C0C0C0"><a
href="./albumsongs.php?albumname=<?=strval( $row['album'] );?>&artistname=<?=strval( $row['artist'] );?>"><?=strval( $row['album'] );?></a> </td>
<td bgcolor="#C0C0C0"><a
href="albums.php?albumname=<?=strval( $row['artist'] );?>"><?=strval( $row['artist'] );?></a> </td>
<td bgcolor="#C0C0C0">276 </td>
</tr>
<? break;
default: ?>
this is some default html
<? endswitch; ?>
<?
} =====end of my while
i want some thing like the pic:
Last edited by tony007; May 22nd, 2006 at 01:10 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|