tommy445 Posted July 13, 2009 Share Posted July 13, 2009 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> "; ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted July 13, 2009 Share Posted July 13, 2009 I'm not sure what you're asking here. Do you want to reduce the width of the table so it matches the width of the data in the table? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted July 13, 2009 Share Posted July 13, 2009 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> "; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.