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>

                        ";

?>

Link to comment
Share on other sites

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>
                        ";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.