dynimic row height

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
assgar
Forum Commoner
Posts: 46
Joined: Fri Apr 20, 2007 9:00 pm

dynimic row height

Post by assgar »

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.

Code: Select all

<?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>";

}

?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Does the generated source give any clues? Take a look at it.
Post Reply