Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何格式化这个动态生成的html表_Php_Mysql_Joomla - Fatal编程技术网

Php 如何格式化这个动态生成的html表

Php 如何格式化这个动态生成的html表,php,mysql,joomla,Php,Mysql,Joomla,我试图从mysql查询中呈现4列,但我无法正确对齐输出值,如何格式化表,使所有4列和标题对齐中心 $tableStyle = "padding: 5px;border:1px"; $tdStyle = "padding:5px "; echo '<table style="' . $tableStyle . '" cellpadding="5" cellspacing="5">'; echo "<tr align='center'> <th>Title

我试图从mysql查询中呈现4列,但我无法正确对齐输出值,如何格式化表,使所有4列和标题对齐中心

$tableStyle = "padding: 5px;border:1px"; 
$tdStyle = "padding:5px "; 

echo '<table style="' . $tableStyle . '" cellpadding="5" cellspacing="5">'; 
echo "<tr align='center'> <th>Title</th><th>Score</th><th>Maximum Score</th><th>Finished On</th></tr>";

$row = $database->loadRowList();
foreach($row as $valuearray)
{
echo '<tr style=" align="center">';
foreach($valuearray as $field)
{

echo "<td align='center'>$field</td>";
}
echo "</tr>";
}
echo "</table>";
$tableStyle=“填充:5px;边框:1px”;
$tdStyle=“padding:5px”;
回声';
回显“TitleScoreMaximum ScoreFinished On”;
$row=$database->loadRowList();
foreach($valuearray行)
{

echo'在另一个有一个单元格的表中用数据包装您的表,并将其居中,使HTML看起来像这样:

<table><tr align='center' valign='middle'><td><table>...</table></td></tr></table>
。。。
$tableStyle=“填充:5px;边框:1px”;
$tdStyle=“padding:5px”;
回声';
回显“TitleScoreMaximum ScoreFinished On”;
$row=$database->loadRowList();
foreach($valuearray行)
{
回声';
foreach($valuearray作为$field)
{
回显“$field”;
}
回声“;
}
回声“;

对齐中心不应放置在tr上

列如何,它会继承所有标题和主体单元格的中心位置吗?您的表格保持不动且不改变。它的作用是将表格置于较大单元格的中心位置。以下是一个示例:测试
$tableStyle = "padding: 5px;border:1px"; 

$tdStyle = "padding:5px "; 

echo '<table style="' . $tableStyle . '" cellpadding="5" cellspacing="5">'; 
echo "<tr> <th align='center'>Title</th><th align='center'>Score</th><th align='center'>Maximum Score</th><th align='center'>Finished On</th></tr>";

$row = $database->loadRowList();
foreach($row as $valuearray)
{
echo '<tr>';
foreach($valuearray as $field)
{

echo "<td align='center'>$field</td>";
}
echo "</tr>";
}
echo "</table>";