943,946 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 2925
  • PHP RSS
Jul 31st, 2007
0

dynamic row height

Expand Post »
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 Syntax (Toggle Plain Text)
  1. <?php
  2. $query = "SELECT event_id, event_date, event_time
  3. FROM cal_appointment
  4. WHERE status = 'A'
  5. ORDER BY event_date, event_time";
  6.  
  7. $result = mysqli_query($mysqli, $query) or die('Error, query failed');
  8. /************************ this section displays the events*************************/
  9.  
  10. echo "<table width=\"100%\" border=\"0\">";
  11. echo"<tr align=\"center\" bgcolor=\"#FFFFFF\">";
  12. echo" <td width=\"100%\" >
  13. <div id=\"Layer2\" style=\"position:absolute; width:100%; height:100px; z-index:2; left: 8px; top: 310px;\">
  14. <div id=\"scroll-box2\" style=\"overflow: auto; float: left; width: 100%; height: 240px; margin: 5px; \">\n";
  15. //table begins
  16. echo "<table width=\"98%\" height=\"310\" left =\"4\" border=\"0\" font face =\"arial\">\n";
  17. $result = mysqli_query($mysqli,$query) or die('Error, query failed');
  18. $num_rows = mysqli_num_rows($result);
  19. for($i=0; $i < $num_rows; $i++)
  20. {
  21. $row = mysqli_fetch_array($result);
  22. list($event_id, $event_date, $event_time) = $row;
  23.  
  24. /**convert 24hr time to 12 hr**/
  25. list($hour, $min, $sec) = split(":",$event_time);
  26. if($hour > 12)
  27. {
  28. $time_hour = $hour - 12;
  29. }
  30. else
  31. {
  32. $time_hour = $hour;
  33. }
  34.  
  35. //format time of day
  36. if($hour < 12)
  37. {
  38. $tod = "AM";
  39. }
  40. else
  41. {
  42. $tod = "PM";
  43. }
  44. $time = "$hour:$min $tod";
  45. echo "<tr>";
  46. echo"<td width=\"18%\" height=\"15\" align=\"center\">$time</td>
  47. <td width=\"12%\" height=\"15\">$event_date</td>\n";
  48. echo "</tr>";
  49.  
  50. }//end for
  51.  
  52. echo "</table>";
  53. echo "</td>";
  54. echo "</tr>";
  55. echo "</div>";
  56. echo "</div>";
  57. echo "</table>";
  58. }
  59. ?>
Last edited by assgar; Jul 31st, 2007 at 1:06 pm. Reason: code tags
Similar Threads
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006
Jul 31st, 2007
0

Re: dynamic row height

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.
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Jul 31st, 2007
0

Re: dynamic row height

Thanks for the response.

You were right the table height was the issue.
Reputation Points: 24
Solved Threads: 0
Junior Poster in Training
assgar is offline Offline
89 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how to use subform?
Next Thread in PHP Forum Timeline: Is there any problem wid ths code?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC