Skip to content

Commit 4f4b3ae

Browse files
author
=Sujan Shakya
committed
adds table caption feature
1 parent fd63106 commit 4f4b3ae

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

HtmlTable.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ class HtmlTable {
152152
public $thead;
153153
public $tbody;
154154
public $caption = '';
155-
public $capid = "";
156-
public $capclass = "";
155+
public $caption_attributes = "";
157156

158157
private function set_attributes($attributes) {
159158
$this->attributes=$attributes;
@@ -178,7 +177,12 @@ public function get_html() {
178177
}
179178

180179
private function create_content() {
181-
return $this->thead->get_html().$this->tbody->get_html();
180+
$caption_content='';
181+
if(trim($this->caption)!='') {
182+
$temp = new HtmlElement('caption',$this->caption,$this->caption_attributes);
183+
$caption_content = $temp->get_html();
184+
}
185+
return $caption_content.$this->thead->get_html().$this->tbody->get_html();
182186
}
183187
}
184188

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class for creating dynamic html table
44
Usage Example:
55

66
$t=new HtmlTable('class="table"');
7+
$t->caption="Testing Table";
8+
$t->caption_attributes='style="font-weight: bold;"';
79
$t->thead->add_row();
810
$t->thead->th_array(array(
911
'SN',

0 commit comments

Comments
 (0)