login  Naam:   Wachtwoord: 
Registreer je!
 Forum

Herhaling SELECT-attribuut

Offline dbe123 - 12/09/2011 15:28 (laatste wijziging 12/09/2011 15:30)
Avatar van dbe123Lid Hoi Sitemasters.
Ik zit met een vreemd probleem.

Ik gebruik onderstaande Code in mijn View een Table te laten zien:
  1. <?php
  2. echo $grid->render_grid($session->full_access());
  3. ?>


De functie render_grid ziet er als volgt uit:
  1. public function render_grid($full_access=false) {
  2. $row_class = "";
  3.  
  4. $object_array = self::find_all();
  5. $sql = "SELECT DISTINCT name FROM " . self::$table_name . " ORDER BY name ASC";
  6. $name_array = self::find_by_sql($sql);
  7. $sql = "SELECT DISTINCT department FROM " . self::$table_name . " ORDER BY department ASC";
  8. $department_array = self::find_by_sql($sql);
  9. $sql = "SELECT DISTINCT country FROM " . self::$table_name . " ORDER BY country ASC";
  10. $country_array = self::find_by_sql($sql);
  11.  
  12. $output = "<table class=\"data table-autosort table-autofilter table-autopage:15 table-stripeclass:alternate table-page-number:t1page table-page-count:t1pages table-filtered-rowcount:t1filtercount table-rowcount:t1allcount\" id=\"t1\">";
  13. $output .= "<thead>";
  14. $output .= "<tr>";
  15. $output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Name<br />";
  16. $output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
  17. $output .= "<option value=\"\">Filter: All</option>";
  18. // foreach ($name_array as $name) {
  19. // $output .= "<option value=\"{$name->name}\">{$name->name}</option>";
  20. // }
  21. $output .= "</select>";
  22. $output .= "</th>";
  23. $output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Department<br />";
  24. $output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
  25. $output .= "<option value=\"\">Filter: All</option>";
  26. // foreach ($department_array as $department) {
  27. // $output .= "<option value=\"{$department->department}\">{$department->department}</option>";
  28. // }
  29. $output .= "</select>";
  30. $output .= "</th>";
  31. $output .= "<th title=\"Click to sort\" class=\"table-filterable table-sortable:default table-sortable\">Country<br />";
  32. $output .= "<select class=\"table-autofilter\" onclick=\"Table.cancelBubble(event)\" onchange=\"Table.filter(this,this)\">";
  33. $output .= "<option value=\"\">Filter: All</option>";
  34. // foreach ($country_array as $country) {
  35. // $output .= "<option value=\"{$country->country}\">{$country->country}</option>";
  36. // }
  37. $output .= "</select>";
  38. $output .= "</th>";
  39. $output .= "</tr>";
  40. $output .= "</thead>";
  41. $output .= "<tbody>";
  42. if ($full_access) {
  43. foreach ($object_array as $object) {
  44. $output .= "<tr class=\"{$row_class}\">";
  45. $output .= "<td><a href=\"division_edit.php?id={$object->id}\">{$object->name}</a></td>";
  46. $output .= "<td>{$object->department}</td>";
  47. $output .= "<td>{$object->country}</td>";
  48. $output .= "</tr>";
  49. if ($row_class == "") {
  50. $row_class = "alternate";
  51. } else {
  52. $row_class = "";
  53. }
  54. }
  55. } else {
  56. foreach ($object_array as $object) {
  57. $output .= "<tr class=\"{$row_class}\">";
  58. $output .= "<td>{$object->name}</td>";
  59. $output .= "<td>{$object->department}</td>";
  60. $output .= "<td>{$object->country}</td>";
  61. $output .= "</tr>";
  62. if ($row_class == "") {
  63. $row_class = "alternate";
  64. } else {
  65. $row_class = "";
  66. }
  67. }
  68. }
  69. $output .= "</tbody>";
  70. $output .= "<tfoot>";
  71. $output .= "<tr>";
  72. $output .= "<td class=\"table-page:previous\" style=\"cursor:pointer;\">&lt; &lt; Previous</td>";
  73. $output .= "<td style=\"text-align:center;\">Page <span id=\"t1page\"></span>&nbsp;of <span id=\"t1pages\"></span></td>";
  74. $output .= "<td class=\"table-page:next\" style=\"cursor:pointer;\">Next &gt; &gt;</td>";
  75. $output .= "</tr>";
  76. $output .= "<tr>";
  77. $output .= "<td colspan=\"3\"><span id=\"t1filtercount\"></span>&nbsp;of <span id=\"t1allcount\"></span>&nbsp;rows match filter(s)</td>";
  78. $output .= "</tfoot>";
  79. $output .= "</table>";
  80.  
  81. return $output;
  82. }


Alles werkt, alleen wordt mijn filter herhaald. Ik zie dus 2 DropDowns onder elkaar, in mijn TH staan. Ik kan echter nergens vinden waar deze vandaan komen!
Een screenshot van het probleem:
Screenshot

Ziet iemand waarom de filter herhaald wordt?  

1 antwoord

Gesponsorde links
Offline Stijn - 17/09/2011 01:35
Avatar van Stijn PHP expert Wat verteld de html broncode in de browser?
Gesponsorde links
Je moet ingelogd zijn om een reactie te kunnen posten.
Actieve forumberichten
© 2002-2024 Sitemasters.be - Regels - Laadtijd: 0.215s