Skip to content

Instantly share code, notes, and snippets.

@lloc
Created October 1, 2011 15:04
Show Gist options
  • Save lloc/1256152 to your computer and use it in GitHub Desktop.
Save lloc/1256152 to your computer and use it in GitHub Desktop.
MySQL Example 1
<?php
$link = mysql_connect("mysql_host", "mysql_user", "mysql_password")
or die("Keine Verbindung möglich: " . mysql_error());
echo "Verbindung zum Datenbankserver erfolgreich";
mysql_select_db("Meine_Datenbank") or die("Auswahl der Datenbank fehlgeschlagen");
$query = "SELECT * FROM Meine_Tabelle";
$result = mysql_query($query) or die("Anfrage fehlgeschlagen: " . mysql_error());
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "\n";
mysql_free_result($result);
mysql_close($link);
?>
@lloc
Copy link
Author

lloc commented Oct 1, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment