PHP 数组显示不显示所有列


PHP array display does not display all columns

我设法让复选框来发布数据并在结帐页面上显示每个复选框,但我遇到的问题是当它到达第 4 列时它会停止当它达到某个字符限制时也如何将其转换为结帐页面上的表格。

数据库代码段代码:

print '<td><input type="checkbox" name="check_list[]"value='. $getColumn[0]. $getColumn[1].     $getColumn[2]. $getColumn[3]. $getColumn[4].  $getColumn[5].$getColumn[6].$getColumn[7].$getColumn[8].$getColumn[9].'</td>';
for ($column = 1; $column < pg_num_fields($res); $column++)
{   
print "<td>" . $getColumn[$column] . "</td>"; 
}
}
print '</table>'

结帐页面

<?php
echo "<hr />'n";
$res = pg_query ($con, "select count(ref) from music");
$a = pg_fetch_row($res);
echo "<p>Total " . $a[0] . " music in database.</p>";
echo "<table border='1'>'n<thead>'n<tr>'n";
echo "<th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th>     <th>Price</th><th>Description</th>'n";
echo "</tr>'n</thead>'n<tbody>'n";
$res=pg_query($con, "SELECT * from music ORDER BY ref");
while ($a = pg_fetch_array ($res))
{
echo "<tr>";
for ($j = 0; $j < pg_num_fields($res); $j++) {
  // htmlspecialchars converts things like & to HTML entity codes
      echo "<td>" . htmlspecialchars($a[$j], ENT_QUOTES) . "</td>";
    }
 echo "</tr>'n";
 }
echo "</tbody>'n</table>";

?>

敢肯定,您尝试执行以下操作:

print '<table>';
for ($column = 1; $column < pg_num_fields($res); $column++) {
    echo '<tr>';
    print '<td><input type="checkbox" name="check_list[]" value="'.$getColumn[$column] .'" /></td>';
    print "<td>" . $getColumn[$column] . "</td>";
    echo '</tr>';
}
print '</table>';