samoht Posted September 4, 2007 Share Posted September 4, 2007 ok I need help with this one Anyway, I want to have all the tables that my loop produces be the same height - so I thought adding padding to the bottom would be the easiest way. The problem is that I populate these tables base on a db field and I dont let the table have more than 15 check boxes Here is my code for populating the tables: <?php $max_per_col = 15; $current_type = ""; $feature_num = 0; echo '<table border="1" cellspacing="0" cellpadding="0" align="left" style="padding-bottom:1em;"><tr>'; while ($row = mysql_fetch_assoc($rsAllFeatures)) { //If new type show new type header if ($current_type != $row['Type']) { //If not first type close previous type if ($current_type != "") { echo "</table><table border='1' cellspacing='0' cellpadding='0' align='left' style='padding-bottom:2em'>\n"; $feature_num = 0; } $current_type = $row['Type']; echo "\n\t<tr><td class='sb' width='125' >$current_type:</td></tr>\n"; } echo "<tr><td style=\"font-size:9px\" width='125' ><input onClick=\"changeColor(this.id, '#009900');\" type=\"checkbox\" name=\"FeatureId[]\" id=\"FeatureId$row[FeatureId]\" value=\"$row[FeatureId]\""; foreach($ItemsFeatures as $FeatureId){ if($FeatureId==$row['FeatureId']) echo "checked"; } echo ">"; echo "<label id=\"LabelFeatureId".$row['FeatureId']."\" for=\"FeatureId".$row['FeatureId']."\">".$row['Name']."</label></td></tr>\n"; //echo $row['Name'] . "<br>\n"; $feature_num++; //If the 15th item close td and start new one if ($feature_num >= $max_per_col) { echo "</table><table border='1' cellspacing='0' cellpadding='0' align='left' style='padding-bottom:2em'>\n";//"</td><td>\n"; $feature_num = 0; } } echo "</td></tr></table>\n";?> Any Ideas how to determine the extra padding needed at the end of each table? possibly a count of some sort?? Quote Link to comment https://forums.phpfreaks.com/topic/67919-equal-padding-on-repeating-tables/ Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 Can you explain that a little bit differently? It would seem to me that if you have the same number of rows (15) in every table, the heights would match anyway. Quote Link to comment https://forums.phpfreaks.com/topic/67919-equal-padding-on-repeating-tables/#findComment-341425 Share on other sites More sharing options...
samoht Posted September 4, 2007 Author Share Posted September 4, 2007 yes, except I start a new table if the "type" is different. I have a $feature_num but all my declarations are for starting the new table or tr - so if I say: if ($current_type != "") { $pad = 15 - $feature_num; echo "</table><table border='1' cellspacing='0' cellpadding='0' align='left' style='padding-bottom:".$pad."em'>\n"; $feature_num = 0; } I get the padding that should apply to the previous table not the current one. Will I have to restructure my loops? Quote Link to comment https://forums.phpfreaks.com/topic/67919-equal-padding-on-repeating-tables/#findComment-341430 Share on other sites More sharing options...
lemmin Posted September 4, 2007 Share Posted September 4, 2007 I think the best way to do it is to increment a counter ever time a row (<tr>) is printed in the current table. When you go to a new table, use that counter to print extra rows if it stops before that number. You can set a static height for all the rows or just put a in the empty rows. If you don't want to add extra rows, I would still use the counter, but you would have to figure out a relation between padding and the number of rows in the previous table. Quote Link to comment https://forums.phpfreaks.com/topic/67919-equal-padding-on-repeating-tables/#findComment-341434 Share on other sites More sharing options...
samoht Posted September 4, 2007 Author Share Posted September 4, 2007 ok- maybe something like this: if($tr_num < $max_per_col) { for($t=0; $t<= $max_per_col-$tr_num; $t++) { echo "\n\t<tr><td> </td></tr>\n"; } } but where would it go? Quote Link to comment https://forums.phpfreaks.com/topic/67919-equal-padding-on-repeating-tables/#findComment-341460 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.