3 回答

TA貢獻1796條經(jīng)驗 獲得超4個贊
由于您的列位于數(shù)組中,因此您可以foreach()在行上方。列的顯示要么需要足夠好,要么只保留默認值,以使顯示看起來合理......
while($row=pg_fetch_assoc($result)){
echo "<tr>";
foreach ( $row as $key => $value ) {
echo "<td align='center' width='200'>" . $value . "</td>";
}
echo "</tr>";
}

TA貢獻1943條經(jīng)驗 獲得超7個贊
嘗試 :
while($row=pg_fetch_assoc($result)){
echo "<tr>";
$maxColumnDisplay = 100;
foreach($row as $col){
if(!$maxColumnDisplay--) break;
echo "<td align='center' width='200'>" . $col . "</td>";
}
echo "</tr>";
}

TA貢獻2019條經(jīng)驗 獲得超9個贊
嘗試這個:
function printTable(&$result) //result set
{
/** Set up Table and Headers **/
$fieldinfo = $result->fetch_fields();
echo '<table class="sqldump">' . "\n";
echo '<tr class="header">' . "\n";
foreach ($fieldinfo as $fieldval) {
echo "<td>".$fieldval->name."</td>\n";
}
echo "</tr>\n";
/** dump rows **/
while($row = $result->fetch_assoc()) {
echo "<tr>";
foreach ($row as $column) {
echo "<td>".$column."</td>\n";
}
echo "</tr>";
}
echo "</table>\n";
/** gc **/
$result->free();
}
- 3 回答
- 0 關(guān)注
- 145 瀏覽
添加回答
舉報