jjacquay712 Posted December 2, 2008 Share Posted December 2, 2008 im using this code to echo a database table into an html table. it works, but it echos out 7x as many columns as i need, its hard to explain, so heres a demo: http://johnj.gknu.com/post.php Here is my Code: <table width="200" border="1"> <?php mysql_connect(hidden); mysql_select_db(hidden); $query = mysql_query("SELECT * FROM comments"); $query1 = mysql_query("SELECT * FROM comments"); echo '<tr>'; while ($array1 = mysql_fetch_array($query1)) { foreach ($array1 as $value1 => $lol1) { if ( !is_int($value1) ) { echo '<td>' . $value1 . '</td>'; } } } echo '</tr>'; while ($array = mysql_fetch_array($query)){ echo '<tr>'; foreach ($array as $value => $lol) { if ( !is_int($value) ) { echo '<td>' . $lol . '</td>'; } } echo '</tr>'; } ?> </table> any reasons it might be doing this? Thanks, John Link to comment https://forums.phpfreaks.com/topic/135147-for-each-loop-problem-when-echoing-database-table/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.