Hi
I am having a problem with the height of my dynamically create rows.
The data is retrived properly form the database, the issue is displaying the rows.

When there are alot of results to dusplay the rows are displayed correctly.
If there are a few rows the hight can be 3 times the height as when there alot of rows.

Note: Below is a simplified version of the code.

<?php 
$query = "SELECT event_id, event_date, event_time
FROM cal_appointment
WHERE status = 'A'
ORDER BY event_date, event_time";
 
$result = mysqli_query($mysqli, $query) or die('Error, query failed');
/************************ this section displays the events*************************/
 
echo "<table width=\"100%\" border=\"0\">";
echo"<tr align=\"center\" bgcolor=\"#FFFFFF\">";
echo" <td width=\"100%\" >
<div id=\"Layer2\" style=\"position:absolute; width:100%; height:100px; z-index:2; left: 8px; top: 310px;\">
<div id=\"scroll-box2\" style=\"overflow: auto; float: left; width: 100%; height: 240px; margin: 5px; \">\n";
//table begins
echo "<table width=\"98%\" height=\"310\" left =\"4\" border=\"0\" font face =\"arial\">\n";
$result = mysqli_query($mysqli,$query) or die('Error, query failed');
$num_rows = mysqli_num_rows($result);
for($i=0; $i < $num_rows; $i++)
{
$row = mysqli_fetch_array($result);
list($event_id, $event_date, $event_time) = $row;
 
/**convert 24hr time to 12 hr**/
list($hour, $min, $sec) = split(":",$event_time);
if($hour > 12)
{
$time_hour = $hour - 12;
}
else
{
$time_hour = $hour;
}
 
//format time of day
if($hour < 12)
{
$tod = "AM";
}
else
{
$tod = "PM";
}
$time = "$hour:$min $tod";
echo "<tr>";
echo"<td width=\"18%\" height=\"15\" align=\"center\">$time</td>
<td width=\"12%\" height=\"15\">$event_date</td>\n";
echo "</tr>";
 
}//end for
 
echo "</table>";
echo "</td>";
echo "</tr>";
echo "</div>";
echo "</div>";
echo "</table>";
}
?>

I would assume that is because you have explicitly set the table height. If you only give it a couple of rows, those rows will fill the available height.

Thanks for the response.

You were right the table height was the issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.