mac007 Posted March 13, 2010 Share Posted March 13, 2010 Hello, all: have this tiny bit of code, and for the life of me, cant get the table-rows to break in the right place; it does it fine for very first row, but then it doesnt end rows accordingly for rest of records... where should I be putting the tags?? appreciate help... <CODE> <?php $columns = 0; $columnsCounter = 2; echo "<table border='1'> <tr>"; while ($row = mysql_fetch_array($products)) { echo "<td>" . $row['title']. "<br>"; echo " </td>"; $columns++; if ($columns == $columnsCounter) { echo "</tr><tr>"; } $columns == 0; } echo "</tr></table>"; ?> </CODE> Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/ Share on other sites More sharing options...
harristweed Posted March 13, 2010 Share Posted March 13, 2010 at first glance you have a brace too many echo " </td>"; $columns++; if ($columns == $columnsCounter) { echo "</tr><tr>"; } $columns == 0; } should be echo " </td>"; $columns++; if ($columns == $columnsCounter) { echo "</tr><tr>"; $columns == 0; } Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/#findComment-1025621 Share on other sites More sharing options...
mac007 Posted March 13, 2010 Author Share Posted March 13, 2010 thank you Harris... well, that last brace is the closing for the while-loop that appears in the beginning... Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/#findComment-1025622 Share on other sites More sharing options...
harristweed Posted March 13, 2010 Share Posted March 13, 2010 ok, try $columns = 0; $columnsCounter = 2; echo "<table border='1'> <tr>"; while ($row = mysql_fetch_array($products)) { echo "<td>" . $row['title']. "<br> </td>"; $columns++; if ($columns == $columnsCounter) { echo "</tr><tr>"; $columns == 0; } } echo "</tr></table>"; Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/#findComment-1025640 Share on other sites More sharing options...
mac007 Posted March 13, 2010 Author Share Posted March 13, 2010 Thanks Harris... hmm... no, didnt work, did same thing... it breaks first row at right place, but not rows after.. see image attached of how it's showing... where the "white mug" should be in new third row... but isnt! thanks for your help... [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/#findComment-1025645 Share on other sites More sharing options...
mac007 Posted March 13, 2010 Author Share Posted March 13, 2010 Well, found the error... I guess after you stare at code so long, one pretty much loses all real consciousness... This section should have just one = (not ==)!!! coudl kill mysself!! if ($columns == $columnsCounter) { echo "</tr><tr>"; $columns = 0; } Quote Link to comment https://forums.phpfreaks.com/topic/195120-help-witht-this-table-column-counter-please-whey-doesnt-it-break-rows-properly/#findComment-1025664 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.