有人可以帮我找到一个在echo语句中的每一行之间添加&的位置。在哪里以及如何在每行之间添加空格?请忽略已注释掉的第一组echo语句。谢谢......
<link rel="stylesheet" href="docfullcss.css">
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'employee_info';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(! $conn ) {
die('Could not connect: ' . mysqli_connect_error());
}
$sql = 'SELECT * FROM `docfull` ORDER BY `COL 7` ASC';
$retval = mysqli_query($conn,$sql);
if(! $retval ) {
die('Could not get data: ' . mysqli_error($conn));
}
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {
/* (ignore this commented section)
echo "<table>";
echo "<tr>";
echo "<td>COL 1</td>";
echo "<td>COL 2</td>";
echo "</tr>";
echo "</table>";
*/
echo "<tr><td>" . $row['COL 1'] . "</td>
<td>" . $row['COL 2'] . "</td>
</tr>" . $row['COL 3'] . "</td>
<td>" . $row['COL 4'] . "</td>
<td>" . $row['COL 5'] . "</td>
<td>" . $row['COL 6'] . "</td>
<td>" . $row['COL 7'] . "</td>
<td>" . $row['COL 8'] . "</td>
<td>" . $row['COL 9'] . "</td>
<td>" . $row['COL 10'] . "</td>
<td>" . $row['COL 11'] . "</td>
<td>" . $row['COL 12'] . "</td>
<td>" . $row['COL 13'] . "</td>
<td>" . $row['COL 14'] . "</td>
<td>" . $row['COL 15'] . "</td>
<td>" . $row['COL 16'] . "</td><td>";
echo "<br><br>";
}
mysqli_close($conn);
?>
答案 0 :(得分:1)
问题在这里
echo "<tr><td>" . $row['COL 1'] . "</td><td>" . $row['COL 2'] .
"</td></tr>" . $row['COL 3'] .
您在COL 2
之后结束行,并且永远不会重新开始直到另一次迭代。您需要在</tr>
之后移除此COL 2
并将<td>
添加到此地点,并在</tr>
之后添加. $row['COL 16'] . "</td><td>";
,同时您也不需要td
<br>
{1}}以及下一行的echo '<table>';
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {
echo "<tr><td>" . $row['COL 1'] . "</td>
<td>" . $row['COL 2'] . "</td>
<td>" . $row['COL 3'] . "</td>
<td>" . $row['COL 4'] . "</td>
<td>" . $row['COL 5'] . "</td>
<td>" . $row['COL 6'] . "</td>
<td>" . $row['COL 7'] . "</td>
<td>" . $row['COL 8'] . "</td>
<td>" . $row['COL 9'] . "</td>
<td>" . $row['COL 10'] . "</td>
<td>" . $row['COL 11'] . "</td>
<td>" . $row['COL 12'] . "</td>
<td>" . $row['COL 13'] . "</td>
<td>" . $row['COL 14'] . "</td>
<td>" . $row['COL 15'] . "</td>
<td>" . $row['COL 16'] . "</td></tr>";
}
echo '</table>';
个标记。
要拥有简单的表,你需要这样的东西:
ng-repeat