echo '<tr><td>' . $row->cat_id . '</td><td>' . $row->isbn . '</td></tr>'; } echo "</table>"; } // calling function from class to display all stored date from table authors $authors = books::allbooks("author"); if ($authors !== false) { echo "<h1> Author Table </h1>"; print "<table>\n <tr>\n <th> author_id </th>\n <th> f_name </th>\n <th> l_name </th>\n </tr>"; foreach ($authors as $row) { echo '<tr><td>' . $row->author_id . '</td><td>' . $row->f_name . '</td><td>' . $row->l_name . '</td></tr>'; } echo "</table>"; } // calling function from class to display all stored date from table authors $authors = books::allbooks("authorbook"); if ($authors !== false) { echo "<h1> Authorbook Table </h1>"; print "<table>\n <tr>\n <th> isbn </th>\n <th> author_id </th>\n </tr>"; foreach ($authors as $row) { echo '<tr><td>' . $row->isbn . '</td><td>' . $row->author_id . '</td></tr>'; } echo "</table>"; } ?> </div> <?php include "includes/footer.inc.php"; ?>
<?php class books extends domDocument { function addBook($title, $author) { $titleElement = $this->createElement("title"); $titleElement->appendChild($this->createTextNode($title)); $authorElement = $this->createElement("author"); $authorElement->appendChild($this->createTextNode($author)); $bookElement = $this->createElement("book"); $bookElement->appendChild($titleElement); $bookElement->appendChild($authorElement); $this->documentElement->appendChild($bookElement); } } $dom = new books(); $dom->load(dirname(__FILE__) . "/book.xml"); $dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker"); print $dom->saveXML();
[expect php] [file] <?php require 'Phalanger.inc'; class books extends domDocument { function addBook($title, $author) { $titleElement = $this->createElement("title"); $titleElement->appendChild($this->createTextNode($title)); $authorElement = $this->createElement("author"); $authorElement->appendChild($this->createTextNode($author)); $bookElement = $this->createElement("book"); $bookElement->appendChild($titleElement); $bookElement->appendChild($authorElement); $this->documentElement->appendChild($bookElement); } } $dom = new books(); $dom->formatOutput = true; $dom->load(dirname(__FILE__) . "/book.xml"); $dom->addBook("PHP de Luxe", "Richard Samar, Christian Stocker"); echo __xml_norm($dom->saveXML());
<?php class books extends domDocument { function addBook($title, $author) { $titleElement = $this->createElement('title'); $titleElement->appendChild($this->createTextNode($title)); $authorElement = $this->createElement('author'); $authorElement->appendChild($this->createTextNode($author)); $bookElement = $this->createElement('book'); $bookElement->appendChild($titleElement); $bookElement->appendChild($authorElement); $this->documentElement->appendChild($bookElement); } } $dom = new books(); $xml = <<<EOM <?xml version='1.0' ?> <books> <book> <title>The Grapes of Wrath</title> <author>John Steinbeck</author> </book> <book> <title>The Pearl</title> <author>John Steinbeck</author> </book></books> EOM; $dom->loadXML($xml); $dom->addBook('PHP de Luxe', 'Richard Samar, Christian Stocker'); print $dom->saveXML();
function get_book_by_id($id_book = "") { $books = new books(); return $books->get_book_by_id($id_book); }
function get_purchases_control() { if (filter_input(INPUT_GET, 'user')) { $obj = new books(); $user = sanitize_string(filter_input(INPUT_GET, 'user')); if ($obj->get_purchases($user)) { echo '{"result":1, "purchases":['; $row = $obj->fetch(); while ($row) { echo json_encode($row); if ($row = $obj->fetch()) { echo ','; } } echo ']}'; } else { echo '{"result":0,"message": "Unsuccessful query"}'; } } }
function bookRating() { $retArray = array(); if (!isset($_SESSION["user"])) { $retArray["error"] = array("code" => 0, "txt" => "Only for authorized."); echo json_encode($retArray); return false; } if (!$_POST || !isset($_POST["ratValue"]) || !isset($_POST["bookID"]) || !$_POST["ratValue"] || !$_POST["bookID"]) { return system::redirect('/'); } $userID = intval($_SESSION["user"]["userID"]); $bookID = intval($_POST["bookID"]); $ratValue = floatval($_POST["ratValue"]); $voteCheck = $this->db->query("SELECT `entryID` FROM `books_rating` WHERE `userID`=? AND `bookID`=?", $userID, $bookID); if (!$voteCheck->getNumRows()) { $this->db->query("INSERT INTO `books_rating` SET `userID`=?,`bookID`=?,`userNick`='?', `ratValue`=?", $userID, $bookID, $_SESSION["user"]["nick"], $ratValue); } else { $this->db->query("UPDATE `books_rating` SET `ratValue`=? WHERE `bookID`=? AND `userID`=?", $ratValue, $bookID, $userID); } $retArray["ratValue"] = books::calculateRating($bookID); if ($retArray["ratValue"]) { $this->db->query("UPDATE `books` SET `rating`=? WHERE `bookID`=?", $retArray["ratValue"], $bookID); } $this->smarty->clearCache(null, "book|{$bookID}"); echo json_encode($retArray); }
public static function connect_it($connection) { books::$conn = $connection; }
$this->price = $par; } public function getprice() { echo $this->price . "<br/>"; } public function settitle($par) { $this->title = $par; } public function gettitle() { echo $this->title . "<br/>"; } } $physics = new books("physics", 800); $physics->settitle("physics"); $physics->setprice(800); //var_dump($physics); $physics->gettitle(); $physics->getprice(); ?> <!--With constructor--> <?php class books1 { var $title; var $price;
<?php include_once "books.php"; include_once "messages.php"; include_once "funciones.php"; session_start(); if (isset($_POST["opt"])) { $bk = new books(); $response = new StdClass(); $mes = new messages(); $fun = new funciones(); switch ($_POST["opt"]) { case 'add': $title = $_POST["title"]; $isbn = $_POST["isbn"]; $autor = $_POST["autor"]; $genre = $_POST["genre"]; $release = $_POST["release"]; $res = $bk->add($title, $isbn, $autor, $genre, $release); if ($res) { $response->res = true; $response->mes = $mes->get_msg("e004"); } else { $response->res = false; $response->mes = $mes->get_msg("e003"); } break; case 'list': $res = $bk->display_list(); if ($res) { $response->res = true;