私のサーバーのPHPが動作していることを確認しました。私はちょうど<? php echo "<p>Hello World</p>"; ?>
である.phpファイルを作るとき、それはうまく動作します。MySQLデータベースからHTMLテーブルを作成しようとしています。何もしないPHP
しかし、私はこのテーブルを構築するために私のコードを使用します。私は自分のページソースにHTMLを取得しません。どうしたの?あなたが手続き的にMySQLiをを使用しているので
$bd = mysqli_connect($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
if (!$db) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
$result = mysqli_query("SELECT * FROM persons"); // selecting data through mysql_query()
echo '<table border=1px>'; // opening table tag
echo'<th>Name</th><th>Email</th><th>Sametime</th><th>Phone Number</th><th>Ranking</th>'; //table headers
while($data = mysqli_fetch_array($result))
{
// we are running a while loop to print all the rows in a table
echo'<tr>'; // printing table row
echo '<td>'.$data['firstname'].$data['lastname'].'</td><td>'.$data['email'].'</td><td>'.$data['sametime'].'</td><td>'.$data['phone'].'</td><td>'.$data['ranking'].'</td>'; // we are looping all data to be printed till last row in the table
echo'</tr>'; // closing table row
}
echo '</table>'; //closing table tag
?>
あなたは少なくともこれを見ますか? "成功:MySQLへの適切な接続が行われました!my_dbデータベースは素晴らしいです。" – pmahomme
'<?php'タグを開いていますか? 'bd'は変数であることを理解していますので、' $ bd'にする必要がありますか? –
最初の行の 'bd'はtypoですか?あなたのコードでは、 '$ db'にする必要があります。 –