Created
October 12, 2017 18:49
-
-
Save yakutozcan/cd329b46ec36f7d64b6b6e7349012b26 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//MySQL veri tabanı ayarları | |
$servername = "localhost"; | |
$username = "root"; | |
$password = ""; | |
$dbname = "arduphp"; | |
//http://yakut-macbook-air.local/arduoku.php?oku | |
if(isset($_GET['oku'])) | |
{ | |
try { | |
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); | |
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
//Tarihe göre sıralama ile SELECT işlemi yaptık | |
$query = $conn->query("SELECT veriler, tarih FROM TBL_Veriler ORDER BY tarih DESC", PDO::FETCH_ASSOC); | |
if ( $query->rowCount() ){ | |
foreach( $query as $row ){ | |
//Veritabanında ki verileri ekrana yazdırıyoruz. | |
print $row['veriler'].":".$row['tarih']."<br />"; | |
} | |
} | |
} | |
catch(PDOException $e) | |
{ | |
echo $sql . $e->getMessage(); | |
} | |
}else{ | |
echo "merhaba okuyucu"; | |
} | |
$conn = null; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment