【发布时间】:2013-03-07 14:11:39
【问题描述】:
我正在尝试在 while 循环中显示一个表格,其中每行有 3 行和 3 个 td。但我很困惑如何归档它。
这是我目前的代码:
while($row = mysqli_fetch_array($result)){
$testimonial = $row['testimonial'];
$cityName = $row['city_name'];
$name = $row['name'];
$imageName = $row['image_name'];
$member = $row['membership_type'];
$testimonial = nl2br($testimonial);
//Create new testimonial output
$output = "<table>\n";
$output .= " <tr>\n";
$output .= " <td>\n";
$output .= " <p>\n";
$output .= " <img src=\"".UPLOAD_DIR.$imageName."\" />";
$output .= " {$testimonial}";
$output .= " </p>\n";
$output .= " <p class=\"name\">{$name}<br />\n";
$output .= " <span>A Teacher - From {$cityName}</span></p>\n";
$output .= " </td>\n";
$output .= " </tr>\n";
$output .= "</table>\n";
echo $output;
}
上面的代码给了我一个多行表,每行 1 个 td。但这不是我预期的结果。
谁能告诉我如何在我的While loop 中显示这样的表格?
【问题讨论】:
-
您的示例与您的描述不符
-
对不起。我需要打印一个包含 3 行和每行 3 个表格单元格的表格。
标签: php mysql while-loop html-table