tqla Posted July 31, 2007 Share Posted July 31, 2007 Hi. This script pulls data from a DB and displays it in an HTML tale: $sql = "SELECT * FROM Clients ORDER BY CreatedOn DESC LIMIT 50"; $result = mysql_query($sql, $conn) or die (mysql_error()); while ($list = mysql_fetch_array($result)) { echo '<table width=\"90%\" border=\"1\"><tr>'; echo '<td>' .$list['CompanyName']. '</td>'; echo '<td>' .$list['CreatedOn']. '</td>'; echo '<td>' .$list[' FName']. '</td>'; echo '<td>' .$list[' LName']. '</td>'; echo '<td>' .$list['Contact']. '</td>'; echo '<td>' .$list['MAddress']. '</td>'; echo '<td>' .$list['MAddress2']. '</td>'; echo '<td>' .$list['MCity']. '</td>'; echo '<td>' .$list['MState']. '</td>'; echo '<td>' .$list['MZip']. '</td>'; echo '<td>' .$list['Phone']. '</td>'; echo '<td>' .$list['Cell']. '</td>'; echo '<td>' .$list['Email']. '</td>'; } echo '</tr></table>'; The problem is that the resulting table does not look the way I want it to. I want the table to look like a uniform table with 13 even columns and rows. Right now a separate table is being created for each individual row and they are stacking on top of each other all uneven - some fiels are being stretched by content, etc... How can I make this to be a 13 column table with all of the info stacked evenly? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/ Share on other sites More sharing options...
hitman6003 Posted July 31, 2007 Share Posted July 31, 2007 $sql = "SELECT * FROM Clients ORDER BY CreatedOn DESC LIMIT 50"; $result = mysql_query($sql, $conn) or die (mysql_error()); echo '<table width=\"90%\" border=\"1\">'; while ($list = mysql_fetch_array($result)) { echo '<tr><td>' .$list['CompanyName']. '</td>'; echo '<td>' .$list['CreatedOn']. '</td>'; echo '<td>' .$list[' FName']. '</td>'; echo '<td>' .$list[' LName']. '</td>'; echo '<td>' .$list['Contact']. '</td>'; echo '<td>' .$list['MAddress']. '</td>'; echo '<td>' .$list['MAddress2']. '</td>'; echo '<td>' .$list['MCity']. '</td>'; echo '<td>' .$list['MState']. '</td>'; echo '<td>' .$list['MZip']. '</td>'; echo '<td>' .$list['Phone']. '</td>'; echo '<td>' .$list['Cell']. '</td>'; echo '<td>' .$list['Email']. '</td></tr>'; } echo '</table>'; Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/#findComment-311552 Share on other sites More sharing options...
tqla Posted July 31, 2007 Author Share Posted July 31, 2007 Thanks hitman6003. I just tried that and the tables still appear to be individual tables stacked on top of eachother. How can I make one table with all of the rows and columns joined? Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/#findComment-311555 Share on other sites More sharing options...
hitman6003 Posted July 31, 2007 Share Posted July 31, 2007 Not sure what you mean. The above will create a single table with each data result on a separate row. Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/#findComment-311562 Share on other sites More sharing options...
tqla Posted July 31, 2007 Author Share Posted July 31, 2007 That's what I thought too. But it doesn't. It creates one table per row. Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/#findComment-311567 Share on other sites More sharing options...
tqla Posted July 31, 2007 Author Share Posted July 31, 2007 AHA! I got it. I needed to move the opening <tabe> up like this: echo '<table width=\"90%\" border=\"1\">'; while ($list = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>' .$list['CompanyName']. '</td>'; echo '<td>' .$list['CreatedOn']. '</td>'; echo '<td>' .$list['FName']. '</td>'; echo '<td>' .$list['LName']. '</td>'; echo '<td>' .$list['Contact']. '</td>'; echo '<td>' .$list['MAddress']. '</td>'; echo '<td>' .$list['MAddress2']. '</td>'; echo '<td>' .$list['MCity']. '</td>'; echo '<td>' .$list['MState']. '</td>'; echo '<td>' .$list['MZip']. '</td>'; echo '<td>' .$list['Phone']. '</td>'; echo '<td>' .$list['Cell']. '</td>'; echo '<td>' .$list['Email']. '</td></tr>'; } echo '</table>'; Quote Link to comment https://forums.phpfreaks.com/topic/62587-solved-help-with-html-tables/#findComment-311571 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.