View Single Post
Join Date: Oct 2006
Posts: 82
Reputation: assgar is an unknown quantity at this point 
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

creating dynamic columns and rows with data

 
0
  #1
May 17th, 2008
Hi

The goal is to allow the user the ability to compare daily schedules of
between 1 to 7 users.

The number of columns/user schedule and column headers
are dynamically created base on user selection.

Each user schedule is set up in columns with the user name
at the top of the column and appointments in the columns.

For a static number of columns in a loop I would use the approach
below to display client names for columns.

I am having problems creating dynmic unique column array names for
client_name.


[php]
  1. //static columns
  2.  
  3. for()
  4. {
  5. echo"<tr>
  6. <td>$client_name1</td>
  7. <td>$client_name2</td>
  8. <td>$client_name3</td>
  9. <td>$client_name4</td>
  10. <td>$client_name5</td>
  11. <td>$client_name6</td>
  12. </tr>";
  13. }
  14.  
  15. [/php]



[php]
  1. <?
  2.  
  3. function calendar_event_list_play($users, $date, $db_host, $db_user, $db_password)
  4. {
  5. //database connnection goes here
  6.  
  7. /**-------------selected database contents stored in arrays---------**/
  8. $group_seg[] = $row;//get user availability
  9. $events[] = $row;//appointments for users
  10. $provider[] = $row;//users names for column header
  11.  
  12. $width = 23;//dymanic column width calculation base on number of user schedules selected
  13.  
  14. /**--------------header with user names--------------**/
  15. echo"<table>
  16. <tr>";
  17.  
  18. //appointmant time header
  19. echo"<td width='$time_slot%'>Time</td>";
  20.  
  21. //user name column header
  22. for($num = 0; $num < count($provider); $num++)
  23. {
  24. $last_name = $provider[$num][last_name];//get provider last name for title
  25.  
  26. echo"<td width='$width%'><a href ='../calendar_form.php>$provider_name</a></td>";
  27. }
  28. echo "</tr>
  29. </table>";
  30.  
  31.  
  32. echo "<table width='100%'>\n";
  33.  
  34. //Loop over to display appointment time 15 min time slots
  35. for($time = $start_time; $time <= $end_time; $time += $add_time)
  36. {
  37. //format 24 hour time interval for passing via url
  38. $interval_24hr = date("H:i:s", $time);
  39.  
  40. /**-----------------------event time listing ------------------------**/
  41. echo "<tr>";
  42.  
  43. //Output the time interval label
  44. echo"<td width='8%' height='15'>
  45. <div id='cal-number' style =''>
  46. <ul>
  47. <li>".date("h:i A", $time)."</li>
  48. </ul>
  49. </div>
  50. </td>";
  51.  
  52. //number of columns
  53. for($i = 0; $i < count($provider); $i++)
  54. {
  55. //loop to display appointments for column
  56. foreach ($events as $event)
  57. {
  58. //Event falls into this hour
  59. if($interval_24hr == $event['event_time'])
  60. {
  61. $client_name = substr($event['last_name'],0,14);
  62. }
  63. else
  64. {
  65. $client_name = "";
  66. }
  67. }//end foreach
  68.  
  69. //number of user columns dynamic with appointments displayed
  70. echo"<td $width%'><a href ='../calendar_event_manage_form.php>$client_name</a></td>";
  71.  
  72. }
  73. echo "</tr>";
  74. }
  75.  
  76. echo "</table>";
  77. }//end function
  78. ?>
  79. [/php]
Reply With Quote