943,634 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 3023
  • PHP RSS
May 17th, 2008
0

creating dynamic columns and rows with data

Expand Post »
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]
PHP Syntax (Toggle Plain Text)
  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]
PHP Syntax (Toggle Plain Text)
  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]
Similar Threads
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: Cutting amount of work and loading time?
Next Thread in PHP Forum Timeline: Can i load my page before displaying it ??





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


Follow us on Twitter


© 2011 DaniWeb® LLC