提问人:harris 提问时间:11/21/2014 最后编辑:marc_sharris 更新时间:5/24/2021 访问量:180
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>";
?>
答:
1赞
vaso123
11/21/2014
#1
我敢肯定,您尝试执行以下操作:
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>';
评论
0赞
vaso123
11/27/2014
我帮不了你,如果你不告诉我,你会得到什么错误。
下一个:如何通过表格中的表单发送复选框
评论
htmlspecialchars($getColumn[$column'])
echo "<p>". htmlspecialchars($selected) ."</p>";
value=
value="abcdefg 1234567"
value=
name="check_list[]"
<input>
>