<?php
$baglanti = mysqli_connect("localhost", "root", "", "testdb");
if ($baglanti == false) {
die("Baglanti Hatası: " . mysqli_connect_error());
}
$sorgu = "SELECT * FROM perTable";
if ($veri = mysqli_query($baglanti, $sorgu)) {
if (mysqli_num_rows($veri) > 0) {
echo "<table>";
echo "<tr><th>id</th><th>ad</th><th>soyad</th><th>email</th></tr>";
while ($kayit = mysqli_fetch_array($veri)) {
echo "<tr>";
echo "<td>" . $kayit["id"] . "</td>";
echo "<td>" . $kayit["ad"] . "</td>";
echo "<td>" . $kayit["soyad"] . "</td>";
echo "<td>" . $kayit["email"] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_free_result($veri);
} else {
echo "Kayıt bulunamadı";
}
} else {
echo "hata: " . mysqli_error($baglanti);
}
mysqli_close($baglanti);
?>
<?php
$baglanti = mysqli_connect("localhost", "root", "", "testdb");
if ($baglanti == false) {
die("Baglanti Hatası: " . mysqli_connect_error());
}
$sorgu = "INSERT INTO perTable (ad, soyad, email) VALUES ('AaaAA', 'BaBB', 'ccaacccc@gmail.com')";
if (mysqli_query($baglanti, $sorgu)) {
echo "Kayıt başarılı";
} else {
echo "hata: " . mysqli_error($baglanti);
}
mysqli_close($baglanti);
?>