<?php
$serveame = "localhost";
$useame = "useame";
$password = "password";
$dbname = "myDB";// Create coection
$co = new mysqli($serveame, $useame, $password, $dbname);
// Check coection
if ($co->coect_error) {
die("Coection failed: " . $co->coect_error);
}$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $co->query($sql);if ($result->num_rows > 0) {
echo "<table><tr><th>ID</th><th>Name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>".$row["id"]."</td><td>".$row["firstname"]." ".$row["lastname"]."</td></tr>";
}
echo "</table>";
} else {
echo "0 results";
}
$co->close();
?>
برچسب:
نویسنده: محمد رضا جوادیان