简体   繁体   English

沿标题的列名称php mysql

[英]column names along their headings php mysql

Helo, I want to print and retrieve column names along their headings or their catagories title .. I'm using the following code to print the column names: 嗨,我想沿着标题或类别标题打印和检索列名称。我正在使用以下代码来打印列名称:

$arrlength=count($sort); 
for($x=0;$x<$arrlength;$x++)   
{   
    echo "  <TD class=\"tr1 td26\"><P class=\"p12 ft4\">".$sort[$x]."</P></TD>";  
}

I want to print the column names along their column headings, how can i retrieve them if i have the following table schema: **col heading 1 - col1 我想沿其列标题打印列名称,如果我具有以下表模式,如何检索它们:** col标题1-col1

col heading 1 - col2
col heading 2 - col1
col heading 2 - col2
col heading 3 - col1
col heading 3 - col2
col heading 3 - col3
col heading 3 - col4


col heading 1     col heading 2     col heading 3
-------------     -------------     -------------------------   
col1    col2      col1    col2      col1   col2   col3   col4

I can store column headings in other table so that It can be replaced or printed in their particular place .. 我可以将列标题存储在其他表中,以便可以在其特定位置替换或打印它。

Thankx in anticipation .. ;) 谢谢Thanx ..;)

To retrieve the column names in php using PDO: 要使用PDO检索php中的列名:

private function showColumns($table_schema, $table_name){
    $stmt = self::$_db->prepare("SELECT column_name, column_key, column_type FROM information_schema.columns WHERE 
                                table_schema = :table_schema AND table_name = :table_name");
    $stmt->execute(array(':table_schema' => $table_schema,':table_name' => $table_name));
    return $stmt->fetchAll();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM