I want to load data from my MySql database and put one field of this database into the text of a button :
<?php
$servername = "localhost";
$username = "prova";
$password = "";
$dbname = "prova";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT nomeCantiere,codiceCommessa,indirizzoCantiere FROM Cantiere";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while ($row = $result->fetch_assoc()) {
echo "nomeCantiere: " . $row["nomeCantiere"] . " - codieCommessa: " . $row["codieCommessa"] . " - indirizzoCantiere" . $row["indirizzoCantiere"] . "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
<input type="button" value="button" />
I'm a beginner with this type of programming.
For now I have managed to do is generate a simple "echo"
.
How can I automatically generate buttons with a value="nomeCantiere"
?