我想从特定查询中回显所有内容。如果echo $ res我只能得到字符串之一。如果更改第二个mysql_result参数,则可以得到第二个,第二个等,但我想要的是所有这些,一个接一个地回显。如何将mysql结果转换为可以使用的结果?
我试过了:
$query="SELECT * FROM MY_TABLE"; $results = mysql_query($query); $res = mysql_result($results, 0); while ($res->fetchInto($row)) { echo "<form id=\"$row[0]\" name=\"$row[0]\" method=post action=\"\"><td style=\"border-bottom:1px solid black\">$row[0]</td><td style=\"border-bottom:1px solid black\"><input type=hidden name=\"remove\" value=\"$row[0]\"><input type=submit value=Remove></td><tr></form>\n"; }
$sql = "SELECT * FROM MY_TABLE"; $result = mysqli_query($conn, $sql); // First parameter is just return of "mysqli_connect()" function echo "<br>"; echo "<table border='1'>"; while ($row = mysqli_fetch_assoc($result)) { // Important line !!! Check summary get row on array .. echo "<tr>"; foreach ($row as $field => $value) { // I you want you can right this line like this: foreach($row as $value) { echo "<td>" . $value . "</td>"; // I just did not use "htmlspecialchars()" function. } echo "</tr>"; } echo "</table>";