When i try to call a php file using "href" in a html page, i get an error:
"Parse error: syntax error, unexpected '>' in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\1.php on line 43".
I don't know what is wrong on line 43, here is the code:
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "wt_database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT cod, rated_power, max_output_power, output_voltage, generator_type, rotor_diameter, turbine_weight, design_lifetime, price FROM turbine_specs";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table>
<tr>
<th>Cod</th>
<th>Rated Power</th>
<th>Maximum Output Power</th>
<th>Output Voltage</th>
<th>Generator Type</th>
<th>Rotor Diameter</th>
<th>Turbine Weight</th>
<th>Design Lifetime</th>
<th>Price</th>
</tr>
// output data of each row
while($row = $result->fetch_assoc()) {
echo "
<tr>
<td>" . $row["cod"]. "</td>
<td>" . $row["rated_power"]. "</td>
<td>" . $row["max_output_power"]. "</td>
<td>" . $row["output_voltage"]. "</td>
<td>" . $row["generator_type"]. "</td>
<td>" . $row["rotor_diameter"]. "</td>
<td>" . $row["turbine_weight"]. "</td>
<td>" . $row["design_lifetime"]. "</td>
<td>" . $row["price"]. "</td></tr>
}
echo "</table>";
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>
I saved the file containing this code into my "localhost" folder as a ".php" file.
Image with containing titles of my mysql table
PS:Sorry if my english is bad.
PS2:I am a beginner.