1<?php
2$mysqli = new mysqli("localhost", "user", "password", "database");
3if ($mysqli->connect_errno) {
4 die("Verbindung fehlgeschlagen: " . $mysqli->connect_error);
5}
6$id = 100;
7$sql = "SELECT * FROM tabelle WHERE id < ?";
8$statement = $mysqli->prepare($sql);
9$statement->bind_param('i', $id);
10$statement->execute();
11
12$result = $statement->get_result();
13
14
15while($row = $result->fetch_object()) {
16 echo $row->spaltenname;
17}
18
19//Alternativ mit fetch_assoc():
20while($row = $result->fetch_assoc()) {
21 echo $row['spaltenname'];
22}
23
24?>
25