HTML テーブルに MySQL レコードを表示する際に問題が発生しています
コードは次のとおりです。
<html> <head> </head> <body> <?php $con = mysql_connect("localhost", "root", ""); if (!con) { die ("Can not connect: " . mysql_error()); } mysql_select_db ("regform", $con); $sql = "SELECT * FROM contacts"; $myData = mysql_query($sql, $con); echo 'test'; echo "<table border = '1'> <tr> <th>Name</th> <th>Lastname</th> <th>Phone</th> <th>Email</th> <th>Comment</th> </tr>"; while($record = mysql_fetch_array($myData)) { echo "<tr>"; echo "<td>" . $record['Name'] . "</td>"; echo "<td>" . $record['Lastname'] . "</td>"; echo "<td>" . $record['Phone'] . "</td>"; echo "<td>" . $record['Email'] . "</td>"; echo "<td>" . $record['Comment'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close ($con); ?> </body> </html>
私はブラウザでこれを取得します:
名前 姓 電話 メール コメント "; while($record = mysql_fetch_array($myData)) { echo ""; echo "" . $record['Name'] . ""; echo "" . $record['Lastname'] . ""; echo "" . $record['Phone'] . ""; echo "" . $record['Email'] . ""; echo "" . $record['Comment'] . ""; echo " "; } echo ""; mysql_close ($con); ?>