MDanz Posted March 28, 2010 Share Posted March 28, 2010 what i'm trying to do.. first column 1 cell, next column 2 cells(row span 2), next column 3 cells(row span 3) etc how can i alter the below code to do that. the below code displays results across from column to column then once $max(column max) has been reached displays results on a new row. $foundnum = mysql_num_rows(mysql_query($recent)); $row_count = ceil($foundnum / $max); echo "<table border='0' cellpadding='0' cellspacing='3' >"; //for every $row_count then increase the $row by 1 for($row = 0; $row < $row_count; $row++) { echo "<tr>"; // for every $max then increase the $col by 1 for($col = 0; $col < $max; $col++) { echo "<td></td>"; } echo "</tr>"; } echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/ Share on other sites More sharing options...
Zane Posted March 28, 2010 Share Posted March 28, 2010 Why not just have three columns? Each with a percentage width... col 1 col2 col3 (10%) | (40%) | (50%) Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/#findComment-1032870 Share on other sites More sharing options...
MDanz Posted March 28, 2010 Author Share Posted March 28, 2010 Why not just have three columns? Each with a percentage width... col 1 col2 col3 (10%) | (40%) | (50%) thats not exactly what im trying to do... below is what im trying to accomplish # # # # | # | # Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/#findComment-1032871 Share on other sites More sharing options...
TapeGun007 Posted March 28, 2010 Share Posted March 28, 2010 echo "<td rowspan='$col'></td>" Is this what you are looking for? Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/#findComment-1032874 Share on other sites More sharing options...
MDanz Posted March 28, 2010 Author Share Posted March 28, 2010 nah didn't work... Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/#findComment-1032880 Share on other sites More sharing options...
TapeGun007 Posted March 28, 2010 Share Posted March 28, 2010 Aren't you really trying to increase more than just the rows? If it's only rows, then I made a mistake: echo "<td></td>"; should be replaced with: echo "<td rowspan='$row'></td>"; Regardless, if you are simply trying to make the rowspan and/or colspan a variable size, the HTML code is correct. It looks like, however, that you are also trying to increase the column span. You could literally have a variable width set for both such as: echo "<td rowspan='$row' colspan='$col'></td>"; Quote Link to comment https://forums.phpfreaks.com/topic/196743-for-loop-help/#findComment-1032894 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.