How can PHP and HTML be differentiated in the context of web development?
PHP is a server-side scripting language used for dynamic web development, while HTML is a markup language used for creating the structure of web pages. In web development, PHP is typically embedded within HTML to add dynamic content or functionality to web pages. PHP code is enclosed within <?php ?> tags, while HTML code is enclosed within <html> </html> tags.
<?php
// PHP code to retrieve data from a database and display it within an HTML table
$conn = mysqli_connect("localhost", "username", "password", "database");
$sql = "SELECT * FROM table";
$result = mysqli_query($conn, $sql);
echo "<table>";
while($row = mysqli_fetch_assoc($result)) {
echo "<tr><td>" . $row['column1'] . "</td><td>" . $row['column2'] . "</td></tr>";
}
echo "</table>";
mysqli_close($conn);
?>