Daten Abfragen mit PHP aus MySQL Datenbank mysqli
<?php
$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
die("Verbindung fehlgeschlagen: " . $mysqli->connect_error);
}
$id = 100;
$sql = "SELECT * FROM tabelle WHERE id < ?";
$statement = $mysqli->prepare($sql);
$statement->bind_param('i', $id);
$statement->execute();
$result = $statement->get_result();
while($row = $result->fetch_object()) {
echo $row->spaltenname;
}
//Alternativ mit fetch_assoc():
while($row = $result->fetch_assoc()) {
echo $row['spaltenname'];
}
?>