noalyss
Version-6.7.2
|
Static Public Member Functions | |
static | sql2table ($cn, $a_col, $sql, $table_style='class="result"', $a_sql_var=null) |
Receives a SQL command and returns a string with the HTML code to display it as a table. | |
static | test_me () |
Definition at line 26 of file class_html_table.php.
static Html_Table::sql2table | ( | $ | cn, |
$ | a_col, | ||
$ | sql, | ||
$ | table_style = 'class="result"' , |
||
$ | a_sql_var = null |
||
) | [static] |
Receives a SQL command and returns a string with the HTML code to display it as a table.
Simple table without any feature (link in certain cell, sort,...)
$cn | database object |
$a_col | header of the column it is an array of array indexes are link, name,image, style |
$sql | query to execute |
$table_style | style of the table $a_sql_var array variable for the $sql DEFAULT NULL static function test_me() { $cn=new Database(Dossier::id()); $order=" order by f_id desc "; $url=HtmlInput::get_to_string(array("gDossier","test_select")); if ( isset($_GET['sb'])) { $order=" order by f_id"; $img="image/select1.gif"; } else { $url=$url."&sb=as"; $img="image/select2.gif"; } $sql="select f_id,name,quick_code from vw_client $order limit 10"; echo $sql; echo Html_Table::sql2table($cn, array( array('name'=>'N° de fiche', 'style'=>'text-align:right', 'link'=>$url, 'image'=>$img), array('name'=>'Nom', 'style'=>'text-align:right'), array('name'=>'QuickCode') ) , $sql ); } |
Definition at line 75 of file class_html_table.php.
References $cn, $e, $r, $ret, $row, $sql, $style, Database\fetch_row(), h(), Database\num_row(), and td().
Referenced by test_me().
{ $r=''; $r=sprintf('<table %s>',$table_style); $r.='<tr>'; for ( $i=0;$i <count($a_col);$i++) { $content=h($a_col[$i]['name']); $style=(isset($a_col[$i]['style']))?$a_col[$i]['style']:""; if ( isset($a_col[$i]['image']) && $a_col[$i]['image'] != '') { $content=sprintf('<img src="%s" border="0"></img>%s',$a_col[$i]['image'],$content); } if ( isset($a_col[$i]['link']) ) { $content=sprintf('<a href="%s">%s</a>', $a_col[$i]['link'], $content); $r.="<th $style>$content</th>"; } else $r.= "<th $style>". h($content)."</th>"; } $r.='</tr>'; $ret=$cn->exec_sql($sql,$a_sql_var); for ($i=0;$i<Database::num_row($ret);$i++) { $r.='<tr>'; $row=Database::fetch_row($ret,$i); for ($e=0;$e<count($row);$e++) { $style='';$content=h($row[$e]); if ( isset($a_col[$e]['style']) ) $style=$a_col[$e]['style']; if ( isset ($a_col[$e]['raw'])) $r.='<td $style>'.$row[$e].'</td>'; else $r.=td($content,$style); } $r.='</tr>'; } $r.='</table>'; return $r; }
static Html_Table::test_me | ( | ) | [static] |
Definition at line 120 of file class_html_table.php.
References $_GET, $cn, $img, $order, $sql, $url, echo, HtmlInput\get_to_string(), Dossier\id(), and sql2table().
{ $cn=new Database(Dossier::id()); $order=" order by f_id desc "; $url=HtmlInput::get_to_string(array("gDossier","test_select")); if ( isset($_GET['sb'])) { $order=" order by f_id"; $img="image/select1.gif"; } else { $url=$url."&sb=as"; $img="image/select2.gif"; } $sql="select f_id,name,quick_code from vw_client $order limit 10"; echo $sql; echo Html_Table::sql2table($cn, array( array('name'=>'N° de fiche', 'style'=>'text-align:right', 'link'=>$url, 'image'=>$img), array('name'=>'Nom', 'style'=>'text-align:right'), array('name'=>'QuickCode') ) , $sql ); }