Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
<?php // 1. Verbindung aufbauen $mysqli = new mysqli("localhost", "root", "", "world"); if ($mysqli->connect_error) { echo "Verbindungsfehler: " . mysqli_connect_error(); exit(); } if(!$mysqli->set_charset("utf8")) { exit("Zeichensatz UTF-8 konnte nicht gesetzt werden!"); } // 2. Abfrage(n) senden $sql = 'SELECT * FROM country'; $ergebnis = $mysqli->query($sql); // 3. Ergebniss(e) verarbeiten und ausgeben echo "<p>Es wurden " .$ergebnis->num_rows ." Länder gefunden.</p>\n"; while ($zeile = $ergebnis->fetch_object()) { echo "Das Land ". $zeile->Name ." gehört zu " .$zeile->Continent .". Es hat ca. ". $zeile->Population. " Einwohner.<br>\n"; } $ergebnis->close(); // 4. Verbindung schließen $mysqli->close(); ?>

Stuck with a problem? Got Error? Ask AI support!

Copy Clear