Formatting the results of a MySQL query as if it were run from the console

后端 未结 7 2139
清酒与你
清酒与你 2020-12-16 15:04

I\'m writing a quick and dirty reporting script that queries a report and emails the results. When using the MySQL console the results are in a nicely formatted table:

相关标签:
7条回答
  • 2020-12-16 15:35

    You could use exec or backticks and actually run it from the command line through php. Apparently the mysql command has a -H switch you can use, and it will output HTML formatted. Haven't tried it though, but that might look good too.

    echo '<pre>';
    echo `mysql -u user -ppass -e "select * from table;" database_name`;
    

    2 lines, no pear packages, how much more elegant can it get for a quick and dirty stats page.

    0 讨论(0)
提交回复
热议问题