Bir veritabanına bağlanmak - Bir senaryo öneri?

0 Cevap php
<html><head><title>Library Books</title></head>
<body>
<table border=1>
<tr><th>Book</th><th>Year Published</th><th>Author</th></tr>
<?php
 // connect
 require_once('DB.php');
 $db = DB::connect("mysql://librarian:passw0rd@localhost/library");
 if (DB::iserror($db)) {
   die($db->getMessage(  ));
 }
 // issue the query
 $sql = "SELECT books.title,books.pub_year,authors.name
         FROM books, authors
         WHERE books.authorid=authors.authorid
         ORDER BY books.pub_year ASC";
 $q = $db->query($sql);
 if (DB::iserror($q)) {
   die($q->getMessage(  ));
 }
 // generate the table
 while ($q->fetchInto($row)) {
?>
<tr><td><?= $row[0] ?></td>
    <td><?= $row[1] ?></td>
    <td><?= $row[2] ?></td>
</tr>
<?php
 }
?>

DB.php nasıl komut dosyası çalıştırmak için Seviyorum bakmak gerekir?

Bu işe yaramazsa:

<?php
define("DB_SERVER", "localhost");
define("DB_NAME", "***");
define ("DB_USER", "***");
define ("DB_PASSWORD", "***");
?>

Şimdiden teşekkürler

0 Cevap