* @brief TableWiz helper */ if(!function_exists("tablewiz_create")) { function tablewiz_create($rows, $bind=array(), $domid="", $domclass="", $thead_html="", $tbody_html=array()) { $html = ""; if(count($rows) == 0) { return $html; } $dom_element_name = make_random_id(10); $domid = empty($domid) ? "tablewiz_id_" . $dom_element_name : $domid; $domclass = empty($domclass) ? "tablewiz_class_" . $dom_element_name : $domclass; $html_th_elms = ""; foreach($rows[0] as $k=>$v) { $html_th_text = array_key_empty($k, $bind) ? $k : $bind[$k]; $html_th_elms .= "" . $html_th_text . ""; } $html_th_elms .= $thead_html; // append contents in thead $html_tr_elms = ""; foreach($rows as $idx=>$record) { $html_tr_elms .= ""; foreach($record as $k=>$v) { $html_tr_elms .= "" . $v . ""; } $html_tr_elms .= ""; // append contents in tbody if(count($tbody_html) > $idx) { $html_tr_elms .= $tbody_html[$idx]; } } $html .= << $html_th_elms $html_tr_elms EOF; return $html; } }