Jump to content

mysql display with alternate color table


tommy445

Recommended Posts

Hello,

 

I have a working script pulling data from mysql and into a table with alternate color rows using php.

 

As you can see I am able to adjust size to the table headers how ever I am at a lost in reducing the size to the row data.

 

This is a tricky one, any ideas?

 

$numofrows = @mysql_num_rows($result);

 

print '

                        <table width="650" border="0" cellpadding="0" cellspacing="0">

                          '; print '

                          <TR>

                            <td width="25%"> <font size="2">No.</font></td>

                            <td width="25%"><font size="2">Name</font></td>

                            <td width="50%"><font size="2">Last Name</font></td>

                          </TR>

                          '; for($i = 0; $i < $numofrows; $i++) { $row = @mysql_fetch_array($result);

                          if($i % 2) { print '

                          <TR bgcolor="#CCCCCC"> '; } else { print '

                          <TR bgcolor="#EAEAEA">'; } print "

                            <td>$i</td>

                            <td>" . $row['client_first_name']."</td>

                            <td>" . $row['client_last_name']."</td>

                            "; print "</TR>

                          "; } print "

                        </table>

                        ";

?>

print '
                        <table width="650" border="0" cellpadding="0" cellspacing="0">
                          '; print '
                          <tr> 
                            <td width="163"><font size="2">No.</font></td>
                            <td width="162"><font size="2">Name</font></td>
                            <td width="325"><font size="2">Last Name</font></td>
                          </tr>
                          '; for($i = 0; $i < $numofrows; $i++) { $row = @mysql_fetch_array($result); 
                          if($i % 2) { print ' 
                          <tr bgcolor="#CCCCCC"> '; } else { print ' 
                          <tr bgcolor="#EAEAEA">'; } print " 
                            <td width=\"163\">$i</td>
                            <td width=\"162\">" . $row['client_first_name']."</td>
                            <td width=\"325\">" . $row['client_last_name']."</td>
                            "; print "</tr>
                          "; } print " 
                        </table>
                        ";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.